:root {
  --ink: #17202f;
  --muted: #5f6b7d;
  --primary: #1f8a70;
  --primary-strong: #176a56;
  --accent: #f77f00;
  --paper: #f8faf8;
  --card: rgba(255, 255, 255, 0.83);
  --line: rgba(23, 32, 47, 0.12);
  --shadow: 0 20px 50px rgba(15, 40, 32, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 18%, #d7f4e6, transparent 42%),
    radial-gradient(circle at 90% 12%, #ffe5c4, transparent 38%),
    linear-gradient(145deg, #f1faf5 0%, #fdf8ef 100%);
  min-height: 100vh;
  position: relative;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
      rgba(31, 138, 112, 0.06) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(31, 138, 112, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 20%, transparent 75%);
  pointer-events: none;
  z-index: -1;
}

.app {
  width: min(1120px, 100% - 1.2rem);
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.hero {
  background: linear-gradient(
    140deg,
    rgba(23, 32, 47, 0.95) 0%,
    rgba(28, 83, 68, 0.94) 70%,
    rgba(247, 127, 0, 0.85) 100%
  );
  color: #fff;
  border-radius: 24px;
  padding: 1.3rem;
  box-shadow: var(--shadow);
  animation: fadeRise 0.6s ease both;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.72rem;
  opacity: 0.85;
}

.hero h1 {
  font-family: Manrope, sans-serif;
  margin: 0.35rem 0;
  font-size: clamp(1.35rem, 3.8vw, 2.15rem);
}

.hero p {
  margin: 0;
  max-width: 70ch;
  line-height: 1.5;
  opacity: 0.95;
}

.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(16, 29, 48, 0.08);
  padding: 1rem;
  animation: fadeRise 0.65s ease both;
}

.controls {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
}

select,
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 11px;
  padding: 0.6rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
}

select:focus,
input[type="number"]:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 70%, white);
  border-color: color-mix(in srgb, var(--primary) 60%, white);
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-field input {
  width: 18px;
  height: 18px;
}

.advanced {
  grid-column: 1 / -1;
}

details {
  border-top: 1px dashed var(--line);
  padding-top: 0.5rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-strong);
}

.advanced-grid {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.summary-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.metric h3 {
  margin: 0.45rem 0;
  font-size: clamp(1.15rem, 3.4vw, 1.7rem);
  font-family: Manrope, sans-serif;
}

.metric small {
  color: var(--muted);
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.table-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.table-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: right;
}

.timeline {
  display: grid;
  gap: 0.6rem;
}

.stage {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem;
  background: linear-gradient(120deg, #fff, #f8fff9);
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  animation: stageIn 0.42s ease both;
}

.stage-left {
  display: flex;
  gap: 0.7rem;
  min-width: 0;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  margin-top: 0.45rem;
  box-shadow: 0 0 0 5px rgba(247, 127, 0, 0.14);
  flex-shrink: 0;
}

.stage-title {
  margin: 0;
  font-size: 0.94rem;
}

.stage-time,
.stage-desc,
.stage-percent {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.stage-right {
  text-align: right;
  min-width: 132px;
}

.stage-amount {
  margin: 0.2rem 0 0;
  font-family: Manrope, sans-serif;
  font-size: 1.03rem;
  color: var(--primary-strong);
}

@keyframes fadeRise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  .controls,
  .summary-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .table-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-head p {
    text-align: left;
  }

  .stage {
    flex-direction: column;
  }

  .stage-right {
    text-align: left;
  }
}
