:root {
  --bg: #eef3f1;
  --bg-accent: #dce7e3;
  --panel: rgba(255, 255, 255, 0.93);
  --panel-strong: #f8fbfa;
  --ink: #16222b;
  --muted: #5f6c74;
  --line: rgba(22, 34, 43, 0.12);
  --brand: #0c7a6a;
  --brand-soft: #dff5ef;
  --highlight: #d8e7e2;
  --danger: #9d3d31;
  --shadow: 0 14px 30px rgba(22, 34, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(12, 122, 106, 0.1), transparent 24rem),
    linear-gradient(180deg, #f6faf8, var(--bg) 38%, var(--bg-accent));
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  overflow-x: clip;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.hero-copy,
.hero-meta,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(24px);
  transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease;
}

body.is-ready .hero-copy,
body.is-ready .hero-meta,
body.is-ready .panel {
  animation: panelRise 720ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

body.is-ready .hero-meta {
  animation-delay: 90ms;
}

body.is-ready .form-panel {
  animation-delay: 160ms;
}

body.is-ready .result-panel {
  animation-delay: 240ms;
}

.hero-copy {
  padding: 2rem;
}

.eyebrow,
.panel-kicker,
.meta-label,
.result-label,
.metric-label,
.notes-title,
.hero-highlight-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.hero h1,
.panel-heading h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.05;
}

.hero h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.9rem);
  max-width: 13ch;
}

.hero-text {
  max-width: 58ch;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.hero-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.hero-highlight {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(248, 251, 250, 0.96);
  opacity: 0;
  transform: translateY(16px);
}

body.is-ready .hero-highlight {
  animation: panelRise 560ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

body.is-ready .hero-highlight:nth-child(1) {
  animation-delay: 210ms;
}

body.is-ready .hero-highlight:nth-child(2) {
  animation-delay: 290ms;
}

body.is-ready .hero-highlight:nth-child(3) {
  animation-delay: 370ms;
}

.hero-highlight strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.35;
}

.hero-meta {
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}

.meta-card {
  padding: 1rem 1.05rem;
  background: var(--panel-strong);
  border-radius: 18px;
  border: 1px solid var(--line);
  opacity: 0;
  transform: translateY(16px);
}

body.is-ready .meta-card {
  animation: panelRise 560ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

body.is-ready .meta-card:nth-child(1) {
  animation-delay: 180ms;
}

body.is-ready .meta-card:nth-child(2) {
  animation-delay: 250ms;
}

body.is-ready .meta-card:nth-child(3) {
  animation-delay: 320ms;
}

.meta-card strong {
  display: block;
  font-size: 1.12rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.5rem;
}

.panel {
  padding: 1.5rem;
}

.panel-heading {
  margin-bottom: 1.25rem;
}

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

.field {
  display: grid;
  gap: 0.5rem;
}

.field span {
  font-weight: 600;
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

.field-wide {
  grid-column: 1 / -1;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: rgba(22, 34, 43, 0.9);
  border-radius: 16px;
  padding: 0.9rem 0.95rem;
  min-height: 3.2rem;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease, background 120ms ease;
}

input::placeholder {
  color: rgba(95, 108, 116, 0.55);
  font-style: italic;
}

select:invalid {
  color: rgba(95, 108, 116, 0.72);
}

select option {
  color: var(--ink);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(12, 122, 106, 0.55);
  box-shadow: 0 0 0 4px rgba(12, 122, 106, 0.12);
}

input.is-invalid,
select.is-invalid {
  border-color: rgba(157, 61, 49, 0.7);
  box-shadow: 0 0 0 4px rgba(157, 61, 49, 0.12);
  background: rgba(255, 248, 247, 0.96);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

button {
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 10px 20px rgba(22, 34, 43, 0.08);
}

.primary-button {
  background: var(--brand);
  color: #f7fffd;
}

.secondary-button {
  background: #e7efe9;
  color: var(--ink);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.notes-block {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(22, 34, 43, 0.1);
  background: rgba(248, 251, 250, 0.9);
}

.notes-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.55;
}

.result-stack {
  display: grid;
  gap: 1rem;
}

.result-content.is-entering > * {
  animation: panelRise 420ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.result-content.is-entering > *:nth-child(1) {
  animation-delay: 0ms;
}

.result-content.is-entering > *:nth-child(2) {
  animation-delay: 45ms;
}

.result-content.is-entering > *:nth-child(3) {
  animation-delay: 90ms;
}

.result-content.is-entering > *:nth-child(4) {
  animation-delay: 135ms;
}

.result-content.is-entering > *:nth-child(5) {
  animation-delay: 180ms;
}

.empty-state {
  min-height: 14rem;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(247, 251, 249, 0.98), rgba(236, 244, 241, 0.92));
  border: 1px solid rgba(12, 122, 106, 0.08);
  color: var(--muted);
}

.hidden {
  display: none;
}

.risk-headline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.risk-value {
  margin: 0;
  font-size: clamp(2.5rem, 4vw, 4rem);
  font-weight: 800;
  line-height: 0.95;
}

.decile-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 7rem;
  padding: 0.8rem 1rem;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--brand-soft), #effaf6);
  border: 1px solid rgba(12, 122, 106, 0.18);
}

.decile-chip span {
  font-size: 0.82rem;
  color: var(--muted);
}

.decile-chip strong {
  font-size: 1.6rem;
}

.result-text {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.6;
}

.recommendation-card {
  margin-bottom: 1rem;
  padding: 1rem 1.05rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(238, 247, 244, 0.92), rgba(255, 255, 255, 0.82));
  border: 1px solid rgba(12, 122, 106, 0.18);
}

.recommendation-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.recommendation-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.recommendation-badge {
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(12, 122, 106, 0.14);
  color: #0c6a5e;
}

.recommendation-badge.is-priority {
  background: rgba(157, 61, 49, 0.12);
  color: var(--danger);
}

.recommendation-text {
  margin: 0.7rem 0 0;
  line-height: 1.6;
  color: var(--ink);
}

.recommendation-footnote {
  margin: 0.7rem 0 0;
  line-height: 1.5;
  color: var(--muted);
  font-size: 0.92rem;
}

.decile-bar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.decile-segment {
  min-height: 4.2rem;
  border-radius: 18px;
  border: 1px solid transparent;
  display: grid;
  align-content: space-between;
  padding: 0.65rem 0.5rem;
  background: rgba(22, 34, 43, 0.06);
  color: var(--muted);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.decile-segment span {
  font-size: 0.72rem;
}

.decile-segment strong {
  font-size: 0.88rem;
  color: var(--ink);
}

.decile-segment.is-active {
  background: linear-gradient(180deg, #0f8b79, #0d6c5f);
  color: #f3fffc;
  border-color: rgba(12, 122, 106, 0.42);
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(12, 122, 106, 0.18);
  animation: activePulse 1.6s ease-out 1;
}

.decile-segment.is-active strong {
  color: #ffffff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.metric-card {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
}

.metric-card strong {
  display: block;
  font-size: 1.18rem;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.decile-table {
  width: 100%;
  border-collapse: collapse;
}

.decile-table th,
.decile-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(22, 34, 43, 0.08);
  font-size: 0.95rem;
}

.decile-table thead th {
  background: rgba(22, 34, 43, 0.04);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.decile-table tbody tr.is-selected {
  background: rgba(12, 122, 106, 0.1);
}

.status-message {
  display: none;
  margin-top: 1rem;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(157, 61, 49, 0.2);
  background: rgba(157, 61, 49, 0.08);
  color: var(--danger);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.45;
}

.status-message.is-visible {
  display: block;
  animation: statusPop 220ms ease-out;
}

@keyframes panelRise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes statusPop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes activePulse {
  0% {
    box-shadow: 0 0 0 rgba(12, 122, 106, 0);
  }
  45% {
    box-shadow: 0 14px 28px rgba(12, 122, 106, 0.26);
  }
  100% {
    box-shadow: 0 12px 22px rgba(12, 122, 106, 0.18);
  }
}

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

  .hero-copy,
  .hero-meta,
  .panel,
  .hero-highlight,
  .meta-card {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 980px) {
  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 0.75rem;
  }

  .hero-copy,
  .panel {
    padding: 1.25rem;
  }

  .hero-highlights {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .risk-headline {
    flex-direction: column;
    align-items: start;
  }

  .decile-bar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .decile-table th,
  .decile-table td {
    padding: 0.7rem 0.75rem;
    font-size: 0.88rem;
  }
}
