/* =====================
   TOOLTIP ICON & CONTENT
====================== */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  position: relative;
  margin-left: 4px;
  color: #475569; /* darker grey for better contrast */
  font-size: 15px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1;
  user-select: none;
  transition: color 0.18s;
}
.tooltip-icon:focus {
  outline: none;
  color: #6366f1;
}
.tooltip-icon:hover,
.tooltip-icon:focus {
  color: #6366f1;
}
.custom-tooltip {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  left: calc(50% - 16px); /* move left by ~2mm (16px at 96dpi) */
  top: 24px; /* move up by ~2mm (was 26px) */
  transform: translateX(-50%) scale(0.96);
  min-width: 160px;
  max-width: 220px;
  background: rgba(15,23,42,0.96);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.18);
  padding: 10px 14px;
  z-index: 10;
  white-space: normal;
  transition: opacity 0.18s, transform 0.18s;
  will-change: opacity, transform;
}
.tooltip-icon:hover .custom-tooltip,
.tooltip-icon:focus .custom-tooltip {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
  transition-delay: 0.2s;
}
.tooltip-icon .custom-tooltip {
  transition-delay: 0s;
}
/* =========================================================
   GLOBAL BASELINE
   ---------------------------------------------------------
   These rules prevent 90% of layout bugs seen on the web:
   - No horizontal overflow
   - Predictable box sizing
   - Stable rendering across browsers
========================================================= */
*,
*::before,
*::after{
  box-sizing: border-box;
}

html, body{
  width:100%;
  max-width:100%;
  margin:0;
  padding:0;
  overflow-x:hidden; /* Never allow sideways scroll */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background:#f1f5f9;
}

main.container{
  padding-bottom:18px;
}

:root{
  --bg:#ffffff;
  --muted:#64748b;
  --primary:#6366f1;
  --success:#16a34a;
  --glass: rgba(15,23,42,0.02);
}

/* Accessibility helper */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* =========================================================
   MAIN FD CALCULATOR LAYOUT
   ---------------------------------------------------------
   Design goals:
   - Fixed-width calculator (left)
   - Flexible result panel (right)
   - NEVER overflow viewport
   - Sticky but header-safe
========================================================= */
.fd-wrapper{
  max-width:1100px;
  margin:0 auto;
  padding:20px;

  display:grid;

  /* CRITICAL RULE:
     minmax(0,1fr) allows shrinking and prevents overflow */
  grid-template-columns: 330px minmax(0, 1fr);

  gap:6px;
  width:100%;
}

/* =========================================================
   LEFT PANEL : INPUT / CALCULATOR
========================================================= */
.fd-calculator-box{
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:20px;
  width:100%;
  display:flex;
  flex-direction:column;

  /* Gentle surface shadow and subtle backdrop */
  box-shadow: 0 6px 18px rgba(15,23,42,0.06);
  background: linear-gradient(180deg,var(--bg),#fbfdff 60%);

  /* Sticky but safe with header */
  position: sticky;
  top: 90px;

  /* Defensive rules */
  height:420px;
  width:320px;
}

/* Spacing between fields */
.fd-field{
  margin-bottom:16px;
}

/* Labels */
.fd-field label {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  margin-bottom: 6px;
  gap: 4px;
}

.fd-select-row{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:12px;
}

.fd-select-group{
  min-width:0;
}

.fd-calculator select{
  width:100%;
  padding:6px 30px 6px 9px;
  font-size:14px;
  border-radius:6px;
  border:1px solid #cbd5e1;
  background:#ffffff;
  color:#0f172a;
}

.fd-calculator select:disabled{
  background:#f1f5f9;
  color:#94a3b8;
  cursor:not-allowed;
}

/* Input + slider row */
.fd-input-row{
  display:grid;
  /* slightly wider input column so large Indian-number formatting fits better */
  grid-template-columns:120px minmax(0,1fr);
  gap:12px;
  align-items:center;
}

/* Text & number inputs */
.fd-calculator input{
  width:100%;
  padding:6px 9px;
  font-size:14px;
  border-radius:6px;
  border:1px solid #cbd5e1;
  background:#ffffff;
}

/* Sliders - styled for modern browsers */
.fd-calculator input[type="range"]{
  /* Reset native appearance for modern browsers */
  -webkit-appearance: none;
  appearance: none; /* standard property for non-prefixed browsers */
  height:6px;
  background: linear-gradient(90deg,var(--primary),rgba(99,102,241,0.6));
  border-radius:6px;
  /* ranges inherit general input padding; reset so track spans full width */
  padding:0;
  margin:0;
  width:100%;
  box-sizing:border-box;
}
.fd-calculator input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:18px;height:18px;border-radius:50%;background:var(--primary);box-shadow:0 2px 6px rgba(99,102,241,0.28);border:3px solid #fff;cursor:pointer;margin-top:-6px;
}
.fd-calculator input[type="range"]::-moz-range-thumb{width:18px;height:18px;border-radius:50%;background:var(--primary);border:none;cursor:pointer}


/* =========================================================
   RIGHT PANEL : RESULTS
========================================================= */
.fd-chart{
  background:#ffffff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  /* reduce top padding to move content slightly up without shifting panel */
  padding:12px 18px 14px;
  width:100%;

  display:flex;
  flex-direction:column;
  align-items:stretch;

  position: sticky;
  top: 90px;

  box-shadow: 0 6px 18px rgba(15,23,42,0.06);

  /* Defensive rules */
  height:420px;
  width:590px;
}

/* Row that contains canvas and side legend */
.fd-chart-row{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px; /* reduced gap so legend sits closer to chart */
  width:100%;
  position:relative;
}

.fd-chart-side{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:8px;
}

/* Vertical legend style */
.fd-chart-legend.vertical{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin:0;
}
.fd-chart-legend.vertical .legend-item{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:14px;
  color:#334155;
}

.fd-chart-legend.vertical .legend-item i{ width:12px;height:12px;border-radius:50%;display:inline-block }

/* =========================================================
   RESULT SUMMARY (TITLE + PILLS)
========================================================= */
.fd-summary-row{
  width:100%;
  display:flex;
  flex-direction:column;   /* 🔑 stack vertically */
  gap:8px;
  margin-bottom:6px;
}


/* Heading */
.fd-summary-title{
  font-size:15px;
  font-weight:600;
  color:#0f172a;
  white-space:nowrap;
}

/* Pills container */
.fd-summary{
  display:flex;
  /* Prevent pills from pushing layout when numbers are very long.
     Keep them on a single line and truncate with ellipsis. */
  flex-wrap:nowrap;
  gap:8px;
  max-width:100%;
  overflow:hidden;
}

/* Individual pill */
.fd-summary > span{
  padding:6px 12px;
  font-size:13px;
  font-weight:500;
  border-radius:999px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  display:inline-flex;
  align-items:center;
  max-width:33%;
}

/* Pill colors */
.fd-summary .principal{
  background:#e0e7ff;
  color:#1e3a8a;
}
.fd-summary .interest{
  background:#dcfce7;
  color:#166534;
}
.fd-summary .maturity{
  background:#fef3c7;
  color:#92400e;
}

/* =========================================================
   PIE CHART
   ---------------------------------------------------------
   Canvas must NEVER overflow parent.
========================================================= */
.fd-chart canvas{
  width:200px !important;
  height:200px !important;
  /* reduce top margin so chart sits higher; remove auto centering so legend sits closer */
  margin:2px 0 12px;
  border-radius:50%;
  cursor:pointer;
}

.fd-pie-tooltip{
  position:absolute;
  min-width:152px;
  max-width:210px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(15,23,42,0.94);
  color:#ffffff;
  font-size:12px;
  line-height:1.35;
  box-shadow:0 10px 24px rgba(15,23,42,0.22);
  pointer-events:none;
  opacity:0;
  transform:translate(10px,-10px) scale(0.96);
  transform-origin:left bottom;
  transition:opacity 160ms ease, transform 160ms ease;
  z-index:3;
  white-space:nowrap;
}

.fd-pie-tooltip.visible{
  opacity:1;
  transform:translate(10px,-10px) scale(1);
}


/* =========================================================
   PIE LEGEND
========================================================= */
.fd-chart-legend{
  display:flex;
  gap:10px;
  font-size:13px;
  color:#334155;
  margin-bottom:8px;
}

.fd-chart-legend i{
  width:10px;
  height:10px;
  border-radius:50%;
  display:inline-block;
  margin-right:5px;
}

.fd-chart-legend .principal{ background:#6366f1; }
.fd-chart-legend .interest{ background:#22c55e; }

/* =========================================================
   BOTTOM RESULT BOXES
========================================================= */
.fd-result-bottom{
  width:100%;
  display:grid;

  /* minmax again to avoid overflow */
  grid-template-columns: repeat(2, minmax(0,1fr));

  gap:12px;
  margin-top:6px;
  padding-top:8px;
}

.fd-chart.payout-mode .fd-result-bottom{
  grid-template-columns: repeat(3, minmax(0,1fr));
}

/* Individual box */
.fd-result-box{
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:10px;
  padding:10px;
  text-align:center;
  min-width:0;
}

/* Box label */
.fd-result-box span{
  display:block;
  font-size:13px;
  color:#64748b;
  margin-bottom:6px;
}

/* Box value */
.fd-result-box strong{
  font-size:22px;
  font-weight:700;
  color:#0f172a;
}

/* Green highlight */
.fd-result-box.green strong{
  color:#16a34a;
}

.fd-result-box.fd-maturity-box strong{
  color:#B45309;
}

.fd-result-box.hidden{
  display:none;
}

/* =========================================================
   BELOW-CALCULATOR CONTENT PANELS
========================================================= */
.fd-info-panel{
  max-width:916px;
  width:100%;
  margin:18px auto 0;
  padding:20px;
  border:1px solid #e5e7eb;
  border-radius:16px;
  background:linear-gradient(180deg,#ffffff 0%,#f8fafc 100%);
  box-shadow:0 10px 28px rgba(15,23,42,0.06);
}

.conclusion-panel{
  max-width:916px;
  padding:8px 16px 8px 10px;
  border-color:#dbeafe;
  background:linear-gradient(180deg,#ffffff 0%,#f8fbff 100%);
  margin-top:0;
  margin-bottom:14px;

  display:flex;
  align-items:center;
  gap:10px;
}

.conclusion-image{
  width:40px;
  height:40px;
  flex:0 0 56px;
  object-fit:contain;
}

.conclusion-copy{
  margin:0;
  flex:1;
  text-align:center;
  color:#0f172a;
  font-size:18px;
  line-height:1.5;
  font-weight:400;
}

.conclusion-amount{
  font-weight:700;
  font-size:20px;
}

.conclusion-principal,
.conclusion-maturity{
  color:#0f172a;
}

.conclusion-interest{
  color:#16a34a;
}

html.dark .conclusion-panel{
  background:var(--bg-card);
  border-color:var(--border-soft);
  box-shadow:var(--shadow-card);
}

html.dark .conclusion-copy{
  color:var(--text-main);
}

html.dark .conclusion-principal,
html.dark .conclusion-maturity{
  color:var(--text-main);
}

html.dark .conclusion-interest{
  color:#4ade80;
}

html.dark .fd-seo-panel{
  background:var(--bg-card);
  border-color:var(--border-soft);
  box-shadow:var(--shadow-card);
}

html.dark .fd-seo-panel h2,
html.dark .fd-seo-panel h3{
  color:var(--text-main);
}

html.dark .fd-seo-panel p,
html.dark .fd-seo-panel li{
  color:var(--text-muted);
}

.fd-panel-head{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:16px;
}

.fd-panel-head h2{
  margin:0;
  font-size:22px;
  color:#0f172a;
}

.fd-panel-head p{
  margin:0;
  color:#64748b;
  font-size:14px;
}

.fd-seo-panel h2,
.fd-seo-panel h3{
  margin:0;
  color:#0f172a;
}

.fd-seo-panel h2{
  font-size:22px;
  margin-bottom:10px;
}

.fd-seo-panel h3{
  font-size:17px;
  margin-top:18px;
  margin-bottom:8px;
}

.fd-seo-panel p,
.fd-seo-panel li{
  margin:0;
  color:#475569;
  font-size:14px;
  line-height:1.65;
}

.fd-seo-panel ul{
  margin:0;
  padding-left:20px;
  display:grid;
  gap:8px;
}

.fd-growth-head{
  flex-direction:row;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}

.fd-growth-legend{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  justify-content:flex-end;
}

.fd-growth-legend span{
  display:inline-flex;
  align-items:center;
  gap:8px;
  color:#334155;
  font-size:13px;
  font-weight:600;
}

.fd-growth-legend i{
  width:12px;
  height:12px;
  border-radius:50%;
  display:inline-block;
}

.fd-growth-legend .invested{ background:#8b5cf6; }
.fd-growth-legend .value{ background:#22c55e; }

.fd-growth-chart-wrap{
  position:relative;
  min-height:320px;
  border:1px solid #e2e8f0;
  border-radius:16px;
  background:linear-gradient(180deg,#ffffff 0%,#f8fafc 100%);
  overflow:hidden;
}

.fd-growth-chart{
  width:100%;
  height:320px;
  display:block;
}

.fd-growth-tooltip{
  position:absolute;
  min-width:150px;
  max-width:220px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(15,23,42,0.94);
  color:#ffffff;
  font-size:12px;
  line-height:1.4;
  box-shadow:0 10px 24px rgba(15,23,42,0.22);
  pointer-events:none;
  opacity:0;
  transform:translate(10px,-10px) scale(.96);
  transform-origin:left bottom;
  transition:opacity 160ms ease, transform 160ms ease;
  z-index:3;
  white-space:nowrap;
}

.fd-growth-tooltip.visible{
  opacity:1;
  transform:translate(10px,-10px) scale(1);
}

.fd-growth-empty{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:24px;
  color:#64748b;
  font-size:14px;
}

.fd-growth-insights{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:14px;
  margin-top:14px;
}

.fd-growth-insight-card{
  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:14px;
  padding:16px;
}

.fd-growth-insight-card span{
  display:block;
  margin-bottom:8px;
  color:#64748b;
  font-size:13px;
}

.fd-growth-insight-card strong{
  display:block;
  color:#0f172a;
  font-size:16px;
  line-height:1.5;
}

.fd-growth-hover-dot{
  cursor:pointer;
}

.fd-growth-invested-point{
  fill:#8b5cf6;
  stroke:#ffffff;
  stroke-width:2;
  opacity:.95;
}

.fd-growth-point{
  fill:#22c55e;
  stroke:#ffffff;
  stroke-width:2;
  opacity:.95;
}

.fd-growth-guide{
  stroke:#86efac;
  stroke-width:1.5;
  stroke-dasharray:5 5;
  opacity:.95;
}

.fd-growth-active-dot{
  fill:#16a34a;
  stroke:#ffffff;
  stroke-width:3;
}

.fd-growth-active-invested-dot{
  fill:#7c3aed;
  stroke:#ffffff;
  stroke-width:3;
}

.fd-insight-grid,
.fd-link-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:14px;
}

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

.fd-question-list{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}

.fd-insight-card,
.fd-link-card{
  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:14px;
  padding:16px;
  min-width:0;
}

.fd-insight-card h3,
.fd-link-card strong{
  display:block;
  margin:0 0 8px;
  color:#0f172a;
  font-size:16px;
}

.fd-insight-card p,
.fd-link-card span{
  margin:0;
  color:#475569;
  font-size:14px;
  line-height:1.55;
}

.fd-question-card{
  display:block;
  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:14px;
  padding:16px 18px;
  text-decoration:none;
  transition:transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.fd-question-card h3{
  margin:0 0 8px;
  color:#0f172a;
  font-size:16px;
}

.fd-question-card p{
  margin:0;
  color:#475569;
  font-size:14px;
  line-height:1.55;
}

.fd-question-card:hover,
.fd-question-card:focus-visible{
  transform:translateY(-2px);
  border-color:#e11d48; /* EMI Calculator red */
  box-shadow:0 10px 24px rgba(225,29,72,0.12); /* EMI Calculator red shadow */
}

.fd-question-cta{
  display:inline-flex;
  margin-top:10px;
  color:#4f46e5;
  font-size:13px;
  font-weight:700;
}

.fd-conversion-hook{
  margin-top:14px;
  padding-top:2px;
}

.fd-conversion-hook a{
  display:inline-flex;
  align-items:center;
  color:#0f172a;
  font-weight:700;
  text-decoration:none;
}

.fd-conversion-hook a:hover,
.fd-conversion-hook a:focus-visible{
  color:#4f46e5;
}

.fd-link-card{
  text-decoration:none;
  transition:transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.fd-link-card:hover,
.fd-link-card:focus-visible{
  transform:translateY(-2px);
  border-color:#e11d48; /* EMI Calculator red */
  box-shadow:0 10px 24px rgba(225,29,72,0.12); /* EMI Calculator red shadow */
}

.fd-related-list{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
}

.fd-related-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:10px 16px;
  border-radius:999px;
  border:1px solid #dbeafe;
  background:#eff6ff;
  color:#1d4ed8;
  text-decoration:none;
  font-weight:600;
  transition:background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.fd-related-pill:hover,
.fd-related-pill:focus-visible{
  background:#dbeafe;
  transform:translateY(-1px);
  box-shadow:0 8px 18px rgba(37,99,235,0.14);
}

/* =========================================================
   RESPONSIVE SAFETY (TABLET & BELOW)
========================================================= */
@media (max-width: 900px){
  .fd-wrapper{
    grid-template-columns: 1fr;
  }

  .fd-calculator-box,
  .fd-chart{
    position: static; /* Disable sticky on small screens */
  }
  .fd-wrapper{padding:12px}
  .fd-calculator-box{width:100%;height:auto}
  .fd-chart{width:100%;height:auto;margin-top:12px}
  .fd-info-panel{margin-top:14px;padding:18px}
  .conclusion-panel{padding:18px}
  .fd-growth-head,
  .fd-growth-insights,
  .fd-insight-grid,
  .fd-link-grid{grid-template-columns:1fr}
  .fd-growth-head{flex-direction:column}
  .fd-growth-legend{justify-content:flex-start}
}

/* On small screens place legend below the canvas again */
@media (max-width: 520px){
  .conclusion-panel{
    flex-direction:column;
    text-align:center;
  }

  .conclusion-image{
    width:32px;
    height:32px;
    flex-basis:32px;
  }

  .fd-chart-row{ flex-direction: column; align-items:center; }
  .fd-chart-side{ align-items:center }
  .fd-chart-legend.vertical{ align-items:center }
  .conclusion-copy{font-size:16px}
  .fd-select-row,
  .fd-chart.payout-mode .fd-result-bottom{
    grid-template-columns: 1fr;
  }
}

/* Simple button styles used by calculators */
.btn{display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;border:1px solid transparent;cursor:pointer;font-weight:600;font-size:14px}
/* Outline / Clear button */
.btn-outline{background:transparent;border:1px solid rgba(15,23,42,0.08);color:var(--primary);padding:8px 14px;border-radius:10px}
.btn-outline:hover{background:rgba(99,102,241,0.06)}
.btn-outline:active{background:rgba(99,102,241,0.10)}
.btn:focus{outline:3px solid rgba(99,102,241,0.14);outline-offset:3px}
.fd-actions{display:flex;justify-content:flex-start}


/* ===========================
   RESPONSIVE: TABLET & BELOW
   =========================== */

@media (max-width: 900px) {
  /* Stack calculator and result vertically */
  .fd-wrapper {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .fd-calculator-box,
  .fd-chart {
    position: static; /* Remove sticky */
    width: 100%;
    height: auto;
    margin-top: 0;
  }
  .fd-info-panel {
    margin-top: 14px;
    padding: 18px;
  }
  .conclusion-panel {
    padding: 18px;
  }

  /* Stack summary, insights, and grids */
  .fd-growth-head,
  .fd-growth-insights,
  .fd-insight-grid,
  .fd-link-grid {
    grid-template-columns: 1fr;
  }
  .fd-growth-head {
    flex-direction: column;
  }
  .fd-growth-legend {
    justify-content: flex-start;
  }
}


/* ===========================
   RESPONSIVE: MOBILE & BELOW
   =========================== */
@media (max-width: 520px) {
  /* Stack conclusion panel vertically */
  .conclusion-panel {
    flex-direction: column;
    text-align: center;
  }
  .conclusion-image {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }
  /* Stack chart row and legend */
  .fd-chart-row {
    flex-direction: column;
    align-items: center;
  }
  .fd-chart-side {
    align-items: center;
  }
  .fd-chart-legend.vertical {
    align-items: center;
  }
  .conclusion-copy {
    font-size: 16px;
  }
  /* Stack select row and result boxes */
  .fd-select-row,
  .fd-chart.payout-mode .fd-result-bottom {
    grid-template-columns: 1fr;
  }
  /* Ensure no horizontal scroll */
  html, body, .fd-wrapper, .fd-calculator-box, .fd-chart, .fd-info-panel {
    max-width: 100vw;
    overflow-x: hidden;
  }
  /* Make chart responsive */
  .fd-growth-chart,
  .fd-chart canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100vw;
  }
  /* Responsive padding for panels */
  .fd-info-panel {
    padding: 12px;
  }
  /* Responsive font sizes for better readability */
  .fd-field label,
  .fd-result-box span,
  .fd-summary-title,
  .fd-growth-insight-card span,
  .fd-growth-insight-card strong {
    font-size: 15px;
  }
}
