/* Redundancy & Early Retirement Calculator – clean layout, aligned with other RC calculators */
.rper-wrap {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 1040px !important;
  margin: 0 auto !important;
  padding: 0 24px;
  color: #0f172a;
}
.rper-wrap * { box-sizing: border-box; }
@media (max-width: 768px) { .rper-wrap { padding: 0 16px; } }
@media (max-width: 480px) { .rper-wrap { padding: 0 12px; } }

.rper-root {
  background: #faf9fc;
  border: 2px solid #e9d5ff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
@media (max-width: 480px) { .rper-root { padding: 16px; } }

/* Hero – one clear message */
.rper-hero {
  background: linear-gradient(135deg, #f5f3ff 0%, #fff 100%);
  border: 2px solid #e9d5ff;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
}
.rper-hero .rper-title {
  margin: 0 0 8px 0;
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.rper-hero .rper-sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: #475569;
  max-width: 60ch;
}
.rper-inst {
  margin-top: 16px;
  padding: 14px 16px;
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-radius: 12px;
  font-size: 14px;
  color: #0c4a6e;
  line-height: 1.5;
}

/* Section cards – consistent spacing, light accent */
.rper-card {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  max-width: 100%;
  min-width: 0;
}
.rper-section--input {
  border-left: 4px solid #0284c7;
  background: #f8fafc;
}
.rper-section--toggles {
  border-left: 4px solid #b45309;
  background: #fffbeb;
}
.rper-section--results {
  border-left: 4px solid #15803d;
  background: #f0fdf4;
}
.rper-section--disclaimer {
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
}

.rper-section-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.rper-section-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
}
.rper-section-desc {
  font-size: 14px;
  color: #475569;
  margin: 0;
  line-height: 1.5;
}

/* Grid – room to breathe, responsive */
.rper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}
@media (max-width: 640px) { .rper-grid { grid-template-columns: 1fr; } }

/* Fields */
.rper-field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 6px 0;
}
.rper-field input,
.rper-field select {
  width: 100%;
  min-width: 0;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 16px;
  background: #fff;
  color: #111827;
  -webkit-appearance: none;
  appearance: none;
}
.rper-field input:focus,
.rper-field select:focus {
  outline: none;
  border-color: #9333ea;
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
}
/* Easier to edit: hide number spinners, keep tap target */
.rper-field input[type="number"] {
  -moz-appearance: textfield;
}
.rper-field input[type="number"]::-webkit-outer-spin-button,
.rper-field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.rper-help {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.4;
}
.rper-help-above { margin: 0 0 8px 0; margin-top: 0; }

/* Buttons */
.rper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.rper-btn {
  border: 2px solid #d1d5db;
  background: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.rper-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}
.rper-btn--primary {
  background: #9333ea;
  border-color: #9333ea;
  color: #fff;
}
.rper-btn--primary:hover {
  background: #7e22ce;
  border-color: #7e22ce;
  color: #fff;
}

/* Badges */
.rper-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 0;
}
.rper-badge {
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}
.rper-badge.rper-ok { background: #dcfce7; border-color: #86efac; color: #166534; }
.rper-badge.rper-bad { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.rper-badge.rper-warn { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* HR */
.rper-hr {
  height: 0;
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 20px 0;
}

/* Results */
.rper-results-intro {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 16px 0;
  line-height: 1.5;
}
.rper-scenario-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.rper-scenario-card {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rper-scenario-card--ok { border-color: #86efac; background: #f0fdf4; }
.rper-scenario-card--warn { border-color: #fcd34d; background: #fffbeb; }
.rper-scenario-card--bad { border-color: #fca5a5; background: #fef2f2; }
/* Per-scenario styling (full / semi / delay) */
.rper-scenario-card--full { border-left-width: 4px; border-left-color: #0ea5e9; background: linear-gradient(135deg, #f0fdfa 0%, #f0fdf4 100%); }
.rper-scenario-card--full.rper-scenario-card--ok { border-left-color: #0d9488; }
.rper-scenario-card--semi { border-left-width: 4px; border-left-color: #d97706; background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); }
.rper-scenario-card--semi.rper-scenario-card--ok { border-left-color: #b45309; }
.rper-scenario-card--delay { border-left-width: 4px; border-left-color: #7c3aed; background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); }
.rper-scenario-card--delay.rper-scenario-card--ok { border-left-color: #6d28d9; }
.rper-scenario-card-emoji {
  font-size: 1.35em;
  line-height: 1;
}
.rper-scenario-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rper-scenario-card-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
}
.rper-scenario-card-status--ok { background: #bbf7d0; color: #166534; }
.rper-scenario-card-status--warn { background: #fef08a; color: #854d0e; }
.rper-scenario-card-status--bad { background: #fecaca; color: #991b1b; }
.rper-scenario-card-headline {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.35;
}
.rper-scenario-card-message {
  font-size: 14px;
  color: #475569;
  margin: 0;
  line-height: 1.45;
  flex: 1;
}
.rper-scenario-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.rper-scenario-card-end { font-size: 14px; font-weight: 700; color: #0f172a; }
.rper-results-detail-title { font-size: 16px; font-weight: 700; margin: 20px 0 12px 0; color: #0f172a; }

/* Scenario comparison explainer */
.rper-compare-explainer {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 2px solid #bfdbfe;
  border-radius: 14px;
}
.rper-compare-explainer-title { font-size: 17px; font-weight: 800; color: #0f172a; margin: 0 0 8px 0; }
.rper-compare-explainer-text { font-size: 14px; color: #475569; margin: 0; line-height: 1.5; }
.rper-table--compare { font-weight: 600; }
.rper-table--compare thead th { background: #f1f5f9; }

/* Chart/timeline explainer */
.rper-chart-explainer { margin-bottom: 12px; }
.rper-chart-explainer-text { font-size: 14px; color: #64748b; margin: 0; line-height: 1.5; font-style: italic; }

/* KPIs */
.rper-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.rper-kpi {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}
.rper-kpi .h { font-size: 12px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.rper-kpi .v { font-size: 18px; font-weight: 800; margin-top: 8px; color: #0f172a; }

/* Timeline section heading (above table) */
.rper-timeline-heading {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f5f3ff 0%, #fef7ff 100%);
  border: 2px solid #e9d5ff;
  border-radius: 14px;
}
.rper-timeline-title {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}
.rper-timeline-tagline {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
  margin: 0;
}
.rper-timeline-table-section { margin-top: 8px; }
.rper-timeline-table-heading {
  font-size: 15px;
  font-weight: 700;
  color: #4b5563;
  margin: 0 0 10px 0;
}

/* Tables */
.rper-tablewrap {
  overflow-x: auto;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.rper-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 700px;
}
.rper-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 700;
  color: #0f172a;
}
.rper-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.rper-table td.rper-timeline-drawfrom {
  background: #f0fdf4;
  font-weight: 600;
  color: #166534;
}
.rper-table td.rper-timeline-events {
  background: #fef3c7;
  font-weight: 600;
  color: #92400e;
}

/* Chart */
.rper-chart-wrap {
  position: relative;
  margin: 16px 0;
  max-width: 100%;
  min-width: 0;
}
.rper-chart {
  width: 100%;
  min-height: 360px;
  height: 360px;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}
.rper-chart .rper-chart-svg { display: block; width: 100%; height: 100%; vertical-align: top; }
.rper-chart-tooltip {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
  min-width: 200px;
  padding: 12px 14px;
  background: #fff;
  border: 2px solid #9333ea;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  font-size: 13px;
  line-height: 1.5;
  color: #0f172a;
}
.rper-chart-tooltip .rper-tt-title { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.rper-chart-tooltip .rper-tt-row { margin: 4px 0; }
.rper-chart-mobile-summary {
  display: none;
  margin: 16px 0 0;
  padding: 18px;
  background: #f8fafc;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  font-size: 15px;
}
.rper-chart-mobile-title { font-weight: 700; color: #0f172a; margin: 0 0 12px 0; }
.rper-chart-mobile-row { margin: 6px 0; display: flex; align-items: baseline; gap: 8px; }
.rper-chart-mobile-label { color: #64748b; min-width: 6em; }
.rper-chart-mobile-note { margin: 12px 0 0 0; font-size: 13px; color: #64748b; line-height: 1.4; }
@media (max-width: 640px) {
  .rper-chart-desktop { display: none; }
  .rper-chart-mobile-summary { display: block; }
}
@media (min-width: 641px) { .rper-chart-mobile-summary { display: none; } }

/* Plan options (What is your plan after redundancy?) */
.rper-plan-options { display: flex; flex-direction: column; gap: 20px; }
.rper-plan-block { padding: 16px; border: 2px solid #e5e7eb; border-radius: 12px; background: #fafafa; }
.rper-plan-block .rper-plan-title { font-size: 16px; font-weight: 700; color: #0f172a; margin: 0 0 8px 0; }
.rper-plan-block .rper-grid { margin-top: 8px; }
.rper-parttime-days { display: flex; flex-wrap: wrap; gap: 8px; }
.rper-days-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.rper-days-btn:hover { background: #f3f4f6; border-color: #d1d5db; color: #374151; }
.rper-days-btn.rper-days-btn--on { background: #9333ea; border-color: #9333ea; color: #fff; }
.rper-days-btn.rper-days-btn--on:hover { background: #7e22ce; border-color: #7e22ce; color: #fff; }

/* Redundancy split (under Redundancy pay section) */
.rper-split-heading { margin-top: 4px; }
.rper-split-title { font-size: 15px; font-weight: 700; color: #0f172a; margin: 0 0 8px 0; }

/* Export (matches Mailer calculators: single CTA, subscribe to download) */
.rper-export-wrap {
  margin-top: 24px;
  padding: 24px;
  border: 2px solid #e9d5ff;
  border-radius: 16px;
  background: linear-gradient(135deg, #f5f3ff 0%, #fef7ff 100%);
  text-align: center;
}
.rper-export-title {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}
.rper-export-desc {
  font-size: 14px;
  color: #475569;
  margin: 0 0 16px 0;
  line-height: 1.5;
  border: none;
  padding-left: 0;
}
.rper-btn-export {
  padding: 16px 32px;
  min-height: 48px;
  font-size: 16px;
  border: 2px solid #9333ea;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #9333ea;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.rper-btn-export:hover {
  background: #7e22ce;
  border-color: #7e22ce;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}
.rper-export-help {
  font-size: 13px;
  color: #64748b;
  margin-top: 12px;
  margin-bottom: 0;
}

/* Static download section (output by PHP, below calculator) */
.rper-download-section {
  margin-top: 24px;
  padding: 24px;
  border: 2px solid #e9d5ff;
  border-radius: 16px;
  background: linear-gradient(135deg, #f5f3ff 0%, #fef7ff 100%);
  text-align: center;
}
.rper-download-section .rper-btn-export { margin: 0; }
.rper-download-section .rper-export-help { margin-top: 12px; margin-bottom: 0; }

/* Toggle (checkbox row) */
.rper-toggle { display: flex; gap: 10px; align-items: flex-start; }
.rper-toggle input { margin-top: 2px; min-width: 20px; min-height: 20px; accent-color: #9333ea; }

/* Yes/No slider (e.g. DB pension) */
.rper-yesno-slider { display: inline-flex; border: 2px solid #e5e7eb; border-radius: 12px; overflow: hidden; background: #f3f4f6; }
.rper-yesno-option { padding: 10px 24px; font-size: 15px; font-weight: 700; border: none; background: transparent; color: #6b7280; cursor: pointer; transition: background 0.2s, color 0.2s; }
.rper-yesno-option:hover { background: #e5e7eb; color: #374151; }
.rper-yesno-option.rper-yesno--on { background: #9333ea; color: #fff; }
.rper-yesno-option.rper-yesno--on:hover { background: #7e22ce; color: #fff; }

/* Retirement income blocks (DB / State / DC) */
.rper-retirement-blocks { display: flex; flex-direction: column; gap: 24px; }
.rper-retirement-block { padding: 16px; border: 2px solid #e5e7eb; border-radius: 12px; background: #fafafa; }
.rper-retirement-heading { margin: 0 0 8px 0; font-size: 16px; font-weight: 700; color: #0f172a; }
.rper-retirement-block .rper-grid { margin-top: 0; }

/* Sub-headings inside sections */
.rper-card .rper-row .rper-noprint + .rper-row { margin-top: 0; }
.rper-card [style*="font-weight:900"] { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }

/* MailerLite modal */
.rper-modal-overlay {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 20px;
  box-sizing: border-box;
}
.rper-modal {
  background: #fff;
  border: 2px solid #9333ea;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1000000;
}
.rper-modal * { box-sizing: border-box; }
.rper-modal-header {
  padding: 20px 24px;
  background: #9333ea;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rper-modal-header h3 { margin: 0; font-size: 18px; font-weight: 800; }
.rper-modal-close {
  background: rgba(255,255,255,0.25);
  border: none;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rper-modal-close:hover { background: rgba(255,255,255,0.35); }
.rper-modal-body { padding: 24px; overflow: auto; color: #0f172a; }
.rper-modal-label { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: block; }
.rper-modal-input {
  font-size: 15px;
  padding: 12px 14px;
  min-height: 48px;
  border: 2px solid #e5e7eb;
  width: 100%;
  border-radius: 10px;
  display: block;
}
.rper-modal-input:focus { outline: none; border-color: #9333ea; box-shadow: 0 0 0 3px rgba(147,51,234,0.2); }
.rper-modal-trust {
  background: #f5f3ff;
  border: 1px solid #e9d5ff;
  padding: 14px 16px;
  border-radius: 12px;
  margin-top: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
}
.rper-modal-footer {
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  background: #fafafb;
}
.rper-modal-overlay .rper-btn { min-height: 44px; font-size: 14px; font-weight: 600; }
.rper-modal-submit { min-width: 160px; }
.rper-modal-error { color: #dc2626; font-size: 13px; margin-top: 6px; font-weight: 600; }
.rper-modal-success { font-size: 16px; font-weight: 800; color: #059669; text-align: center; padding: 24px; }

@media (max-width: 480px) {
  .rper-hero .rper-title { font-size: 22px; }
  .rper-hero { padding: 20px; }
  .rper-card { padding: 18px; }
  .rper-section-title { font-size: 17px; }
  .rper-scenario-cards { grid-template-columns: 1fr; }
  .rper-kpis { grid-template-columns: 1fr; }
  .rper-timeline-table-heading { font-size: 14px; }
  .rper-table th,
  .rper-table td { padding: 10px 8px; font-size: 12px; }
  .rper-table { min-width: 600px; }
  .rper-modal { max-height: 85vh; border-radius: 16px; }
  .rper-modal-header,
  .rper-modal-body { padding: 16px 20px; }
  .rper-modal-footer { padding: 16px 20px; flex-direction: column; }
  .rper-modal-footer .rper-btn { width: 100%; min-width: 0; }
  .rper-export-wrap { padding: 18px; margin-top: 18px; }
  .rper-export-title { font-size: 18px; }
}

/* Horizontal scroll hint for timeline table on small screens */
.rper-tablewrap {
  scrollbar-width: thin;
}
@media (max-width: 768px) {
  .rper-tablewrap::after {
    content: "Scroll \2192";
    display: block;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 0 0;
  }
}

/* Safari / WebKit: backdrop-filter for modal */
@supports ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .rper-modal-overlay { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
}

/* Safe area insets (notched devices, PWA) */
@supports (padding: env(safe-area-inset-left)) {
  .rper-wrap { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
  .rper-modal-overlay { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .rper-btn,
  .rper-btn-export,
  .rper-days-btn,
  .rper-yesno-option { transition: none; }
  .rper-btn-export:hover { transform: none; box-shadow: none; }
}

/* High contrast / focus visible for accessibility */
.rper-btn:focus-visible,
.rper-field input:focus-visible,
.rper-field select:focus-visible,
.rper-modal-close:focus-visible {
  outline: 2px solid #9333ea;
  outline-offset: 2px;
}
.rper-modal-close:hover,
.rper-modal-close:focus {
  -webkit-tap-highlight-color: transparent;
}
