:root {
  --ink: #1c2530;
  --muted: #64707d;
  --line: #d8dde3;
  --panel: #ffffff;
  --soft: #f4f6f8;
  --aia-red: #d31145;
  --blue: #2563eb;
  --teal: #0f766e;
  --shadow: 0 18px 45px rgba(28, 37, 48, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef1f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  max-width: 1480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
}

.app-header,
.panel-heading,
.header-actions,
.legend,
.segmented {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.app-header {
  margin-bottom: 18px;
}

.secondary-link {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.secondary-link:hover {
  border-color: var(--aia-red);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--aia-red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 0;
}

.metric-panel {
  min-height: 108px;
  padding: 18px;
}

.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}

.metric-panel strong {
  display: block;
  font-size: 26px;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  margin-bottom: 18px;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  margin-bottom: 18px;
}

.panel-heading {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.compact-heading {
  padding-bottom: 14px;
}

.status-pill {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
}

.detail-list,
.mechanic-grid {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
}

.detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-list div,
.mechanic-grid div {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 13px;
}

.detail-list span,
.mechanic-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.detail-list strong,
.mechanic-grid strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.info-dot {
  display: inline-grid;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  cursor: help;
}

.detail-list .info-dot {
  display: inline-grid;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 20px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--aia-red);
  box-shadow: 0 0 0 3px rgba(211, 17, 69, 0.12);
}

.primary-button,
.secondary-button,
.segmented button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.secondary-button:hover,
.segmented button:hover {
  border-color: var(--aia-red);
}

.segment-active {
  border-color: var(--aia-red) !important;
  background: var(--aia-red) !important;
  color: #fff !important;
}

.chart-wrap {
  position: relative;
}

.chart-panel canvas {
  width: 100%;
  height: 360px;
  display: block;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  width: min(320px, calc(100% - 16px));
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(28, 37, 48, 0.18);
  padding: 12px;
  pointer-events: none;
  font-size: 12px;
}

.tooltip-date {
  margin-bottom: 8px;
  color: var(--ink);
  font-weight: 900;
}

.tooltip-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
}

.tooltip-line span {
  color: var(--muted);
  font-weight: 800;
}

.tooltip-line strong {
  color: var(--ink);
}

.tooltip-subline {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.tooltip-divider {
  height: 1px;
  margin: 9px 0 7px;
  background: var(--line);
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
}

.legend-swatch.red {
  background: var(--aia-red);
}

.legend-swatch.blue {
  background: var(--blue);
}

.hidden {
  display: none !important;
}

.legend {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.legend i {
  display: inline-block;
  width: 22px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend .red {
  background: var(--aia-red);
}

.legend .blue {
  background: var(--blue);
}

.timeline-viewport {
  padding: 18px 20px 12px;
  overflow-x: auto;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 0;
}

.timeline-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.timeline-chip.charge {
  background: #fff4f7;
  border-color: #f3b7c7;
  color: #9f1239;
}

.timeline-chip.bonus {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.timeline-chip.dividend {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.timeline-chip.withdrawal {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.timeline-chip.topup {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

.timeline-chip.muted {
  color: var(--muted);
}

.timeline-note {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.beta-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  vertical-align: 4px;
}

.compact-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.visual-timeline {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 248, 250, 0.96)),
    repeating-linear-gradient(90deg, rgba(216, 221, 227, 0.32) 0, rgba(216, 221, 227, 0.32) 1px, transparent 1px, transparent 72px);
  padding: 18px;
}

.timeline-value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.timeline-value-card {
  min-height: 114px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 18px rgba(28, 37, 48, 0.1);
  padding: 14px;
  outline: none;
}

.timeline-value-card:hover,
.timeline-value-card:focus,
.age-marker:hover,
.age-marker:focus,
.lane-band:hover,
.lane-band:focus {
  outline: 2px solid rgba(211, 17, 69, 0.35);
  outline-offset: 2px;
}

.timeline-value-card strong,
.timeline-value-card em,
.timeline-value-card small {
  display: block;
}

.timeline-value-card strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.timeline-value-card em {
  margin-top: 8px;
  color: var(--ink);
  font-style: normal;
  font-size: 22px;
  font-weight: 900;
}

.timeline-value-card small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.timeline-value-card.premium {
  background: #4f4698;
  color: #fff;
}

.timeline-value-card.premium strong,
.timeline-value-card.premium em,
.timeline-value-card.premium small {
  color: #fff;
}

.timeline-value-card.dividend {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.timeline-value-card.withdrawal {
  border-color: #fed7aa;
  background: #fff7ed;
}

.timeline-value-card.topup {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.timeline-value-card.maturity {
  border-color: #10b8c7;
}

.timeline-axis {
  position: relative;
  height: 118px;
  margin-bottom: 18px;
}

.policy-bar {
  position: absolute;
  top: 36px;
  height: 42px;
  background: #10b8c7;
  border: 2px solid #0b8794;
  box-shadow: 0 5px 12px rgba(28, 37, 48, 0.18);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  line-height: 38px;
  text-align: right;
}

.policy-bar::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -24px;
  width: 24px;
  height: 42px;
  background: #10b8c7;
  border-right: 2px solid #0b8794;
  border-top: 2px solid #0b8794;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.policy-bar > span {
  position: relative;
  z-index: 1;
  padding-right: 18px;
}

.premium-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  min-width: 170px;
  background: #4f4698;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.age-marker {
  position: absolute;
  top: 82px;
  z-index: 5;
  display: grid;
  width: 38px;
  height: 38px;
  transform: translateX(-50%);
  place-items: center;
  border-radius: 999px;
  border: 1px solid #b7d4e8;
  background: #eef7fb;
  box-shadow: 0 4px 8px rgba(28, 37, 48, 0.12);
  color: #1f83b7;
  font-size: 15px;
  font-weight: 900;
  outline: none;
}

.age-marker.start {
  border-color: #c8c4ee;
  background: #f0effb;
  color: #4f4698;
}

.age-marker.teal {
  border-color: #9ee8ee;
  background: #e7fbfd;
  color: #0b8794;
}

.timeline-lanes {
  display: grid;
  gap: 9px;
}

.timeline-lane {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.lane-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.lane-track {
  position: relative;
  height: 34px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.lane-band,
.lane-empty {
  position: absolute;
  top: 5px;
  min-width: 150px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  padding: 0 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  outline: none;
}

.lane-band.bonus {
  background: #059669;
}

.lane-band.investment {
  background: #047857;
}

.lane-band.performance {
  background: #0f766e;
}

.lane-band.charge {
  background: #f97316;
}

.lane-band.surrender {
  background: #4d7c0f;
}

.lane-band.partial {
  background: #65a30d;
}

.lane-band.cashflow {
  min-width: 8px;
  overflow: visible;
  padding: 0;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.lane-band.cashflow::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%);
  color: inherit;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.lane-band.cashflow.withdrawal {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.lane-band.cashflow.topup {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

.lane-empty {
  left: 12px;
  background: transparent;
  color: var(--muted);
  justify-content: flex-start;
  padding-left: 0;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

#tableOutput {
  position: relative;
}

.projection-sticky-block {
  position: sticky;
  top: 0;
  z-index: 25;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 22px rgba(28, 37, 48, 0.08);
}

.projection-sticky-block .panel-heading {
  border-bottom: 1px solid var(--line);
}

.sticky-table-header {
  position: relative;
  z-index: 1;
  background: #fff;
  scrollbar-width: none;
}

.sticky-table-header::-webkit-scrollbar {
  display: none;
}

#tableOutput thead {
  display: none;
}

.table-status {
  margin: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.table-toolbar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.table-footer {
  display: flex;
  justify-content: center;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.projection-table {
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: center;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: center;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

th:first-child {
  background: var(--soft);
}

#tableOutput th,
.sticky-table-header th {
  z-index: 3;
  height: 48px;
  padding: 7px 8px;
  white-space: normal;
  line-height: 1.15;
  vertical-align: bottom;
}

.sticky-table-header th:first-child,
#tableOutput th:first-child {
  z-index: 4;
}

#tableOutput td {
  padding: 8px;
  transition: background 120ms ease;
}

#tableOutput tbody tr:hover td {
  background: #fff4f7;
}

td {
  font-size: 13px;
}

.source-details,
.inline-details {
  overflow: hidden;
}

.inline-details {
  border-top: 1px solid var(--line);
}

.source-details summary,
.inline-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 18px 20px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.source-details summary::-webkit-details-marker,
.inline-details summary::-webkit-details-marker {
  display: none;
}

.source-details summary::after,
.inline-details summary::after {
  content: "+";
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  background: var(--soft);
  color: var(--aia-red);
  font-weight: 900;
}

.source-details[open] summary::after,
.inline-details[open] summary::after {
  content: "-";
}

.summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.details-body {
  border-top: 1px solid var(--line);
  padding: 18px 20px 20px;
  min-width: 0;
}

.details-form {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

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

.breakdown-grid section {
  border: 1px solid var(--line);
  background: var(--soft);
  min-width: 0;
  padding: 14px;
}

.breakdown-grid h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.breakdown-grid p,
.breakdown-grid li {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.breakdown-grid p {
  margin: 0 0 10px;
}

.compact-table table {
  min-width: 560px;
}

.compact-table th,
.compact-table td {
  padding: 9px 10px;
}

.rate-details {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.rate-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
}

.rate-details summary::-webkit-details-marker {
  display: none;
}

.rate-details summary::after {
  content: "+";
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  background: var(--soft);
  color: var(--aia-red);
  font-weight: 900;
}

.rate-details[open] summary::after {
  content: "-";
}

.rate-details .table-wrap {
  border-top: 1px solid var(--line);
}

.note {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.footer-note {
  padding: 0 0 18px;
}

.faq-list {
  display: grid;
}

.faq-list details {
  border-top: 1px solid var(--line);
}

.faq-list summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 18px 20px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  background: var(--soft);
  color: var(--aia-red);
  font-weight: 900;
}

.faq-list details[open] summary::after {
  content: "-";
}

.faq-answer p {
  margin: 0;
  padding: 0 20px 20px;
  color: var(--muted);
  line-height: 1.55;
}

.faq-control-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px);
  gap: 12px;
  padding: 0 20px 20px;
}

.faq-control-grid label {
  display: grid;
  gap: 8px;
}

.faq-control-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.faq-table {
  width: calc(100% - 40px);
  max-width: calc(100% - 40px);
  margin: 0 20px 20px;
  border: 1px solid var(--line);
}

.faq-table table {
  min-width: 0;
  table-layout: fixed;
}

.faq-table th,
.faq-table td {
  white-space: normal;
}

.faq-table th:first-child,
.faq-table td:first-child {
  width: 86px;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--aia-red);
  box-shadow: var(--shadow);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, background-color 180ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: #a70d34;
}

@media (max-width: 1000px) {
  .summary-grid,
  .setup-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .app-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .setup-grid,
  .insight-grid,
  .detail-list,
  .breakdown-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  .summary-hint {
    display: none;
  }

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline-viewport {
    padding-left: 14px;
    padding-right: 14px;
  }

  .visual-timeline {
    padding: 14px;
  }

  .timeline-lane {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 8px;
  }

  .lane-label {
    font-size: 11px;
  }

  .policy-bar {
    font-size: 13px;
  }

  .policy-bar > span {
    padding-right: 10px;
  }

  .premium-bar {
    min-width: 104px;
    font-size: 11px;
  }

  .table-toolbar .segmented {
    width: 100%;
  }

  .table-toolbar .segmented button {
    flex: 1;
  }

  .table-status,
  .note {
    padding-left: 14px;
    padding-right: 14px;
  }

  .faq-answer p {
    padding-left: 14px;
    padding-right: 14px;
  }

  .faq-table {
    width: calc(100% - 28px);
    max-width: calc(100% - 28px);
    margin-left: 14px;
    margin-right: 14px;
  }

  .back-to-top {
    right: 14px;
    bottom: 14px;
  }
}
