:root {
  --wine: #904042;
  --wine-deep: #6c3032;
  --sage: #9db4ab;
  --ink: #251d1f;
  --muted: #655b5a;
  --panel: #fffdfb;
  --panel-tint: #fff7f1;
  --line: rgba(37, 29, 31, 0.12);
  --shadow: 0 24px 60px rgba(63, 25, 27, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(144, 64, 66, 0.05), transparent 36%),
    linear-gradient(180deg, #fffefe 0%, #fffaf6 100%);
  color: var(--ink);
  font-family: "Roboto", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

h3 {
  margin: 0;
  font-family: "Lora", Georgia, serif;
  letter-spacing: 0;
}

h3 {
  font-size: 1.45rem;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

.scenario-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.control-chip {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(144, 64, 66, 0.14);
  border-radius: 24px;
  background: rgba(255, 253, 251, 0.96);
  box-shadow: 0 12px 24px rgba(63, 25, 27, 0.08);
}

.control-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(144, 64, 66, 0.18);
  border-radius: 999px;
  background: rgba(144, 64, 66, 0.06);
  color: var(--wine);
  cursor: help;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.help-popover {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  width: 220px;
  padding: 10px 12px;
  border: 1px solid rgba(144, 64, 66, 0.14);
  border-radius: 14px;
  background: #fffdfb;
  color: var(--ink);
  box-shadow: 0 18px 38px rgba(20, 10, 10, 0.16);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 10;
}

.help-tip:hover .help-popover,
.help-tip:focus-visible .help-popover {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stepper {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: stretch;
  min-height: 54px;
  border: 1px solid rgba(144, 64, 66, 0.14);
  border-radius: 18px;
  background: rgba(144, 64, 66, 0.04);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.stepper-btn {
  border: 0;
  border-radius: 0;
  background: rgba(144, 64, 66, 0.06);
  color: var(--wine);
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0;
}

.stepper-btn:hover,
.stepper-btn:focus-visible {
  background: rgba(144, 64, 66, 0.14);
}

.controls input,
.controls select {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-left: 1px solid rgba(144, 64, 66, 0.08);
  border-right: 1px solid rgba(144, 64, 66, 0.08);
  border-radius: 0;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  outline: none;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  appearance: textfield;
}

.controls select {
  appearance: none;
  text-transform: capitalize;
  text-align-last: center;
}

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

.controls input::-webkit-outer-spin-button,
.controls input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.view-panel {
  min-width: 0;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(180deg, var(--panel-tint) 0%, var(--panel) 100%);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: grid;
  gap: 12px;
  margin-bottom: 2px;
}

.panel-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.panel-heading-copy {
  width: 100%;
  max-width: none;
}

.pending-panel .panel-heading-copy {
  padding-bottom: 12px;
}

.pending-panel .panel-heading-copy h3 {
  margin-bottom: 10px;
}

.panel-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.growth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guaranteed-badge {
  border: 1px solid rgba(144, 64, 66, 0.18);
  background: rgba(144, 64, 66, 0.08);
  color: var(--wine);
}

.nonguaranteed-badge {
  border: 1px solid rgba(157, 180, 171, 0.28);
  background: rgba(157, 180, 171, 0.14);
  color: #58756b;
}

.panel-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.panel-badge-row.ltc-badge-row .guaranteed-badge {
  margin-left: auto;
}

.panel-badge-row.ltc-badge-row .metric-badge {
  margin-left: 0;
}

.panel-badge-row.heirs-badge-row {
  padding-top: 6px;
}

.panel-badge-row.heirs-badge-row .nonguaranteed-badge {
  margin-left: auto;
}

.metric-badge {
  margin-left: auto;
}

.metric-badge strong {
  color: var(--ink);
  font-size: inherit;
}

.growth-badge strong {
  color: var(--ink);
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
  text-transform: none;
}

.growth-badge .badge-value-uppercase {
  text-transform: uppercase;
}

.metric-badge,
.metric-badge strong,
.metric-badge span {
  white-space: nowrap;
}

.care-inline-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-left: auto;
}

.care-inline-control .control-label {
  flex: 0 0 auto;
  margin: 0;
}

.care-inline-control .stepper {
  grid-template-columns: 42px minmax(72px, 1fr) 42px;
  min-height: 42px;
  border-radius: 999px;
}

.care-inline-control input {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 0.98rem;
}

.care-inline-control .stepper-btn {
  min-width: 42px;
  min-height: 42px;
  font-size: 1.45rem;
}

.chart-wrap,
.pending-chart {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 276px;
}

.chart-wrap svg,
.pending-chart svg {
  min-height: 262px;
  width: min(100%, 1080px);
}

svg {
  display: block;
  width: 100%;
  height: auto;
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
  cursor: pointer;
}

.selected-line {
  stroke: var(--wine);
}

.hit-line {
  fill: none;
  stroke: transparent;
  stroke-width: 24;
  cursor: pointer;
}

.placeholder-line {
  fill: none;
  stroke: rgba(157, 180, 171, 0.9);
  stroke-dasharray: 8 8;
  stroke-linecap: round;
  stroke-width: 4;
}

.axis-text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.axis-title {
  font-size: 12px;
}

.grid-line {
  stroke: rgba(37, 29, 31, 0.08);
  stroke-width: 1;
}

.chart-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.chart-tooltip {
  position: absolute;
  width: min(240px, calc(100% - 24px));
  padding: 18px 22px;
  border: 1px solid rgba(144, 64, 66, 0.16);
  border-radius: 28px;
  background: rgba(255, 253, 251, 0.98);
  box-shadow: 0 18px 40px rgba(63, 25, 27, 0.16);
  pointer-events: none;
}

.chart-tooltip h4 {
  margin: 0 0 12px;
  color: var(--wine);
  font-family: "Lora", Georgia, serif;
  font-size: 1.1rem;
}

.chart-tooltip p {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.4;
}

.chart-tooltip p + p {
  margin-top: 8px;
}

.focus-ring {
  fill: rgba(255, 255, 255, 0.88);
  stroke: rgba(144, 64, 66, 0.22);
  stroke-width: 1.5;
}

.focus-dot {
  stroke: #fffdfb;
  stroke-width: 4;
}

.focus-dot.ltc-dot {
  fill: var(--wine);
}

.focus-dot.heirs-dot {
  fill: #8eab9d;
}

@media (max-width: 1080px) {
  .app-shell {
    width: min(980px, calc(100vw - 24px));
  }

  .panel-topline {
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    padding: 16px 0 28px;
  }

  .view-panel {
    padding: 18px 18px 16px;
  }

  .chart-wrap {
    min-height: 248px;
    margin-left: -12px;
    margin-right: -12px;
  }

  .chart-wrap svg {
    min-height: 236px;
  }

  .chart-tooltip {
    padding: 16px 18px;
  }

  .panel-badge-row {
    align-items: stretch;
  }

  .metric-badge {
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  .panel-topline {
    flex-direction: column;
    align-items: stretch;
  }

  .care-inline-control {
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .care-inline-control .stepper {
    width: 100%;
  }
}
