:root {
  --bg: #eef3f1;
  --surface: #f8fafc;
  --surface-strong: #ffffff;
  --text: #17211d;
  --muted: #5b675f;
  --line: #cbd7d3;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --blue: #1d4ed8;
  --warning: #9a3412;
  --shadow: 0 18px 60px rgba(23, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(29, 78, 216, 0.09), transparent 38%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.intro-copy {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.source-pill {
  flex: 0 0 auto;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 10px 14px;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 18px;
  align-items: stretch;
  min-width: 0;
}

.controls,
.result-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

label,
legend {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.money-input,
.quantity-input,
.stepper,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.money-input {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.money-input span,
.quantity-input span {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  border-right: 1px solid var(--line);
  background: #eef5f4;
  color: var(--accent-dark);
  padding: 0 14px;
  font-weight: 800;
}

.quantity-input {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.money-input input,
.quantity-input input,
.stepper input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0 14px;
  font-size: 1.3rem;
  font-weight: 750;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-dark) 50%),
    linear-gradient(135deg, var(--accent-dark) 50%, transparent 50%);
  background-position:
    calc(100% - 19px) 22px,
    calc(100% - 13px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color: var(--text);
  padding: 0 42px 0 14px;
  font-weight: 750;
}

.info-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  padding: 11px 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.info-box summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 850;
}

.info-box p {
  margin: 10px 0 0;
}

.info-box a {
  display: inline-block;
  margin-top: 10px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.info-box a:hover {
  text-decoration: underline;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 4px;
}

.segmented-wide span {
  font-size: 0.98rem;
  padding: 0 8px;
  text-align: center;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 850;
}

.segmented input:checked + span {
  background: var(--accent);
  color: white;
}

.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  overflow: hidden;
}

.stepper button {
  border: 0;
  background: #eef5f4;
  color: var(--accent-dark);
  font-size: 1.6rem;
  font-weight: 850;
  cursor: pointer;
}

.stepper button:active {
  background: #d9eeeb;
}

.stepper input {
  text-align: center;
}

.result-panel {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.9);
}

.result-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.result-header p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}

.result-header strong {
  display: block;
  color: var(--accent-dark);
  font-size: clamp(3.2rem, 7vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.metrics span {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 1.24rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.explanation,
.limit-line {
  border-left: 4px solid var(--accent);
  background: #eef8f5;
  border-radius: 0 8px 8px 0;
  padding: 13px 14px;
  color: #17423d;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.limit-line {
  border-left-color: var(--blue);
  background: #eef4ff;
  color: #1e3a8a;
}

.is-warning {
  border-left-color: var(--warning);
  background: #fff7ed;
  color: var(--warning);
}

.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.share-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  background: var(--surface-strong);
  color: var(--accent-dark);
  padding: 0 14px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.share-button:hover {
  background: #eef8f5;
}

.share-feedback {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(calc(100% - 22px), 620px);
    padding: 22px 0;
  }

  .intro,
  .workspace {
    display: grid;
  }

  .intro {
    align-items: start;
  }

  .source-pill {
    max-width: 100%;
    white-space: normal;
  }

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

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

  .metrics span {
    min-height: 0;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.8rem;
    line-height: 1.1;
  }

  .intro-copy {
    font-size: 1rem;
  }

  .result-header strong {
    font-size: clamp(2.35rem, 10vw, 2.9rem);
    line-height: 1.04;
  }
}
