/* =========================================================
   EMIFORMULA PROFESSIONAL CALCULATOR V3
========================================================= */

.calculator-page {
  --calc-primary: #4f46e5;
  --calc-primary-dark: #3730a3;
  --calc-primary-soft: #eef2ff;
  --calc-text: #172033;
  --calc-muted: #70798c;
  --calc-border: #e7eaf0;
  --calc-bg: #f7f8fc;
  --calc-white: #ffffff;
  --calc-interest: #f5a623;
  --calc-success: #15966b;
  --calc-danger: #d64545;
}


/* =========================================================
   MAIN CALCULATOR
========================================================= */

.pro-calculator {
  width: 100%;
}

.pro-calculator-header {
  text-align: center;
  margin-bottom: 26px;
}

.pro-calculator-header h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  font-weight: 850;
  letter-spacing: -0.03em;
}

.pro-calculator-header p {
  margin: 8px auto 0;
  max-width: 620px;
  color: var(--calc-muted);
}


/* =========================================================
   PRESETS
========================================================= */

.calc-presets {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.calc-presets::-webkit-scrollbar {
  display: none;
}

.calc-preset {
  flex: 0 0 auto;
  border: 1px solid var(--calc-border);
  background: var(--calc-white);
  color: var(--calc-text);
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 0.86rem;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform .2s ease,
    border-color .2s ease,
    background .2s ease;
}

.calc-preset:hover {
  transform: translateY(-2px);
  border-color: var(--calc-primary);
}

.calc-preset.active {
  background: var(--calc-primary);
  color: #fff;
  border-color: var(--calc-primary);
}


/* =========================================================
   DASHBOARD
========================================================= */

.calc-dashboard {
  display: grid;
  grid-template-columns:
    minmax(280px, 0.82fr)
    minmax(0, 1.55fr);
  gap: 18px;
  align-items: start;
}


/* =========================================================
   INPUT PANEL
========================================================= */

.calc-input-panel {
  position: relative;
  background: var(--calc-white);
  border: 1px solid var(--calc-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 12px 35px rgba(20, 27, 45, 0.06);
}

.calc-panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.calc-panel-title h3 {
  margin: 0;
  font-size: 1.1rem;
}

.calc-panel-title span {
  color: var(--calc-muted);
  font-size: .78rem;
}


/* =========================================================
   INPUT GROUP
========================================================= */

.calc-field {
  margin-bottom: 21px;
}

.calc-field:last-child {
  margin-bottom: 0;
}

.calc-field-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: .84rem;
  font-weight: 750;
  color: var(--calc-text);
}

.calc-live-value {
  color: var(--calc-primary);
  font-weight: 850;
}

.calc-input-box {
  display: flex;
  align-items: center;
  min-height: 54px;
  border: 1.5px solid var(--calc-border);
  border-radius: 15px;
  background: #fff;
  overflow: hidden;
  transition:
    border-color .2s ease,
    box-shadow .2s ease,
    transform .2s ease;
}

.calc-input-box:focus-within {
  border-color: var(--calc-primary);
  box-shadow:
    0 0 0 4px rgba(79, 70, 229, .09);
  transform: translateY(-1px);
}

.calc-prefix,
.calc-suffix {
  padding: 0 15px;
  color: var(--calc-muted);
  font-weight: 800;
}

.calc-input-box input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 54px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 4px;
  font-size: 1.02rem;
  font-weight: 750;
  color: var(--calc-text);
}

.calc-slider {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 13px;
  accent-color: var(--calc-primary);
  cursor: pointer;
}

.calc-range {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--calc-muted);
  font-size: .7rem;
}


/* =========================================================
   TENURE
========================================================= */

.calc-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: #f2f4f8;
}

.calc-toggle button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--calc-muted);
  font-weight: 800;
  cursor: pointer;
  transition:
    background .2s ease,
    color .2s ease,
    box-shadow .2s ease;
}

.calc-toggle button.active {
  background: #fff;
  color: var(--calc-primary);
  box-shadow: 0 2px 8px rgba(20, 27, 45, .08);
}


/* =========================================================
   QUICK ACTION
========================================================= */

.calc-main-button {
  width: 100%;
  min-height: 56px;
  margin-top: 22px;
  border: 0;
  border-radius: 16px;
  background:
    linear-gradient(
      135deg,
      var(--calc-primary),
      #6d5dfc
    );
  color: #fff;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  box-shadow:
    0 10px 25px rgba(79, 70, 229, .22);
  transition:
    transform .2s ease,
    box-shadow .2s ease;
}

.calc-main-button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 14px 30px rgba(79, 70, 229, .28);
}

.calc-main-button:active {
  transform: translateY(0);
}


/* =========================================================
   ADVANCED
========================================================= */

.calc-advanced {
  margin-top: 18px;
  border-top: 1px solid var(--calc-border);
  padding-top: 17px;
}

.calc-advanced summary {
  cursor: pointer;
  color: var(--calc-text);
  font-weight: 800;
  list-style: none;
}

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

.calc-advanced summary::after {
  content: "+";
  float: right;
  color: var(--calc-primary);
  font-size: 1.2rem;
}

.calc-advanced[open] summary::after {
  content: "−";
}

.calc-advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 17px;
}

.calc-small-field label {
  display: block;
  margin-bottom: 6px;
  font-size: .75rem;
  font-weight: 750;
}

.calc-small-field input {
  width: 100%;
  min-height: 45px;
  box-sizing: border-box;
  border: 1px solid var(--calc-border);
  border-radius: 11px;
  padding: 0 11px;
  outline: 0;
}

.calc-small-field input:focus {
  border-color: var(--calc-primary);
}


/* =========================================================
   RESULT SIDE
========================================================= */

.calc-result-panel {
  min-width: 0;
}

.calc-hero {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border-radius: 24px;
  background:
    radial-gradient(
      circle at 90% 10%,
      rgba(255,255,255,.22),
      transparent 32%
    ),
    linear-gradient(
      135deg,
      #4338ca,
      #6366f1
    );
  color: #fff;
  box-shadow:
    0 15px 38px rgba(79, 70, 229, .20);
}

.calc-hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -90px;
  bottom: -90px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

.calc-hero-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-weight: 750;
  opacity: .78;
}

.calc-hero-value {
  margin-top: 8px;
  font-size: clamp(2.3rem, 6vw, 3.8rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.045em;
}

.calc-hero-caption {
  margin-top: 9px;
  opacity: .78;
  font-size: .82rem;
}

.calc-hero-bar {
  height: 7px;
  margin-top: 23px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,.22);
}

.calc-hero-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #fff;
  transition: width 1s cubic-bezier(.2,.8,.2,1);
}


/* =========================================================
   SUMMARY
========================================================= */

.calc-summary {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin-top: 13px;
}

.calc-summary-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--calc-border);
  border-radius: 17px;
  background: #fff;
  box-shadow:
    0 7px 22px rgba(20,27,45,.035);
}

.calc-summary-card span {
  display: block;
  color: var(--calc-muted);
  font-size: .73rem;
}

.calc-summary-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1rem;
  color: var(--calc-text);
}


/* =========================================================
   VISUAL CARDS
========================================================= */

.calc-visual-grid {
  display: grid;
  grid-template-columns:
    minmax(0, .8fr)
    minmax(0, 1.2fr);
  gap: 13px;
  margin-top: 13px;
}

.calc-visual-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--calc-border);
  border-radius: 20px;
  background: #fff;
  box-shadow:
    0 7px 22px rgba(20,27,45,.035);
}

.calc-visual-card h3 {
  margin: 0;
  font-size: .96rem;
}

.calc-visual-card p {
  color: var(--calc-muted);
  font-size: .76rem;
}


/* =========================================================
   DONUT
========================================================= */

.calc-donut-area {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 225px;
}

.calc-donut {
  width: 190px;
  height: 190px;
  overflow: visible;
  transform: rotate(-90deg);
}

.calc-donut-track {
  fill: none;
  stroke: #eef0f5;
  stroke-width: 22;
}

.calc-donut-principal,
.calc-donut-interest {
  fill: none;
  stroke-width: 22;
  stroke-linecap: round;
  stroke-dasharray: 0 440;
  transition:
    stroke-dasharray 1.15s cubic-bezier(.2,.8,.2,1),
    stroke-dashoffset 1.15s cubic-bezier(.2,.8,.2,1);
}

.calc-donut-principal {
  stroke: var(--calc-primary);
}

.calc-donut-interest {
  stroke: var(--calc-interest);
}

.calc-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 13px;
  font-size: .73rem;
  color: var(--calc-muted);
}

.calc-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.calc-dot-principal {
  background: var(--calc-primary);
}

.calc-dot-interest {
  background: var(--calc-interest);
}


/* =========================================================
   BALANCE GRAPH
========================================================= */

.calc-chart {
  height: 230px;
  margin-top: 8px;
}

.calc-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.calc-chart-grid {
  stroke: #edf0f5;
  stroke-width: 1;
}

.calc-chart-area {
  fill: var(--calc-primary-soft);
  opacity: .8;
}

.calc-chart-line {
  fill: none;
  stroke: var(--calc-primary);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation:
    calcChartDraw 1.6s
    cubic-bezier(.2,.8,.2,1)
    forwards;
}

.calc-chart-label {
  fill: var(--calc-muted);
  font-size: 10px;
}

@keyframes calcChartDraw {
  to {
    stroke-dashoffset: 0;
  }
}


/* =========================================================
   SAVINGS
========================================================= */

.calc-savings {
  margin-top: 13px;
  padding: 16px 18px;
  border: 1px solid #d6f0e5;
  border-radius: 16px;
  background: #effaf5;
  color: var(--calc-success);
  font-size: .85rem;
  font-weight: 750;
  animation:
    calcReveal .45s ease both;
}


/* =========================================================
   EXTRA SECTIONS
========================================================= */

.calc-full-card {
  margin-top: 13px;
  padding: 21px;
  border: 1px solid var(--calc-border);
  border-radius: 20px;
  background: #fff;
  box-shadow:
    0 7px 22px rgba(20,27,45,.035);
}

.calc-full-card h3 {
  margin-top: 0;
}

.calc-table-wrap {
  overflow-x: auto;
}

.calc-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

.calc-table th,
.calc-table td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--calc-border);
  text-align: right;
  white-space: nowrap;
  font-size: .78rem;
}

.calc-table th:first-child,
.calc-table td:first-child {
  text-align: left;
}

.calc-table th {
  color: var(--calc-muted);
  font-size: .7rem;
}


/* =========================================================
   REVEAL ANIMATION
========================================================= */

.calc-reveal {
  animation:
    calcReveal .55s cubic-bezier(.2,.8,.2,1)
    both;
}

@keyframes calcReveal {

  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

}


/* =========================================================
   RESET
========================================================= */

.calc-reset {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--calc-muted);
  font-weight: 750;
  cursor: pointer;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 820px) {

  .calc-dashboard {
    grid-template-columns: 1fr;
  }

  .calc-input-panel {
    padding: 19px;
    border-radius: 20px;
  }

  .calc-hero {
    padding: 23px;
    border-radius: 20px;
  }

  .calc-visual-grid {
    grid-template-columns: 1fr;
  }

}


@media (max-width: 520px) {

  .pro-calculator-header {
    margin-bottom: 19px;
  }

  .calc-presets {
    margin-left: -2px;
    margin-right: -2px;
  }

  .calc-summary {
    grid-template-columns: 1fr;
  }

  .calc-summary-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }

  .calc-summary-card strong {
    margin-top: 0;
    text-align: right;
  }

  .calc-advanced-grid {
    grid-template-columns: 1fr;
  }

  .calc-hero-value {
    font-size: 2.65rem;
  }

  .calc-visual-card,
  .calc-full-card {
    padding: 17px;
  }

}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

  .calc-chart-line {
    animation: none;
    stroke-dashoffset: 0;
  }

  .calc-donut-principal,
  .calc-donut-interest,
  .calc-hero-bar-fill,
  .calc-reveal,
  .calc-savings {
    transition: none;
    animation: none;
  }

}


/* =========================================================
   V4 HELP + LIVE UPDATE + LEARNING CONTENT
========================================================= */

.calc-label-with-help,
.calc-heading-with-help {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.calc-help-button {
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  border: 1px solid var(--calc-primary);
  border-radius: 50%;
  background: #fff;
  color: var(--calc-primary);
  font-size: .72rem;
  line-height: 18px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.calc-help-button:hover,
.calc-help-button:focus-visible {
  background: var(--calc-primary);
  color: #fff;
  outline: none;
}

.calc-help-button-light {
  border-color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.12);
  color: #fff;
}

.calc-help-button-light:hover,
.calc-help-button-light:focus-visible {
  background: #fff;
  color: var(--calc-primary);
}

.calc-help-panel {
  margin-top: 14px;
  padding: 15px 16px;
  border: 1px solid #dfe4ff;
  border-radius: 15px;
  background: var(--calc-primary-soft);
  color: var(--calc-text);
}

.calc-help-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calc-help-panel-head strong {
  font-size: .9rem;
}

.calc-help-panel p {
  margin: 7px 28px 0 0;
  color: #4f5870;
  font-size: .82rem;
  line-height: 1.6;
}

.calc-help-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--calc-muted);
  font-size: 1.15rem;
  cursor: pointer;
}

.calc-live-update {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 13px;
  border: 1px solid var(--calc-border);
  border-radius: 13px;
  background: #fafbff;
}

.calc-live-update > div {
  min-width: 0;
}

.calc-live-update strong {
  display: block;
  font-size: .8rem;
}

.calc-live-update span {
  display: block;
  margin-top: 3px;
  color: var(--calc-muted);
  font-size: .7rem;
  line-height: 1.45;
}

.calc-switch {
  position: relative;
  width: 48px;
  min-width: 48px;
  height: 28px;
  display: block;
  cursor: pointer;
}

.calc-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.calc-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #d7dbe5;
  transition: background .2s ease;
}

.calc-switch-track::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.16);
  transition: transform .2s ease;
}

.calc-switch input:checked + .calc-switch-track {
  background: var(--calc-primary);
}

.calc-switch input:checked + .calc-switch-track::after {
  transform: translateX(20px);
}

.calc-switch input:focus-visible + .calc-switch-track {
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}

.calc-heading-with-help {
  display: inline-flex;
}

.calc-learning {
  margin-top: 26px;
  padding-bottom: 30px;
}

.calc-learning-card {
  margin-top: 13px;
  border: 1px solid var(--calc-border);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(20,27,45,.035);
  overflow: hidden;
}

.calc-learning-card > summary {
  padding: 19px 21px;
  cursor: pointer;
  list-style: none;
  font-weight: 850;
  color: var(--calc-text);
}

.calc-learning-card > summary::-webkit-details-marker {
  display: none;
}

.calc-learning-card > summary::after {
  content: "+";
  float: right;
  color: var(--calc-primary);
  font-size: 1.2rem;
}

.calc-learning-card[open] > summary::after {
  content: "−";
}

.calc-learning-content {
  padding: 0 21px 23px;
  color: #465067;
  font-size: .9rem;
  line-height: 1.72;
}

.calc-learning-content h3 {
  margin: 22px 0 7px;
  color: var(--calc-text);
  font-size: 1rem;
}

.calc-learning-content p {
  margin: 10px 0;
}

.calc-learning-content ul {
  margin: 8px 0 14px;
  padding-left: 21px;
}

.calc-formula {
  margin: 14px 0;
  padding: 15px;
  overflow-x: auto;
  border-radius: 13px;
  background: #f5f6fb;
  color: var(--calc-text);
  text-align: center;
  font-weight: 800;
  white-space: nowrap;
}

.calc-faq-list {
  padding: 0 21px 21px;
}

.calc-faq-item {
  border-top: 1px solid var(--calc-border);
}

.calc-faq-item > summary {
  padding: 15px 4px;
  cursor: pointer;
  list-style: none;
  color: var(--calc-text);
  font-size: .88rem;
  font-weight: 800;
}

.calc-faq-item > summary::-webkit-details-marker {
  display: none;
}

.calc-faq-item > summary::after {
  content: "+";
  float: right;
  color: var(--calc-primary);
  font-size: 1.1rem;
}

.calc-faq-item[open] > summary::after {
  content: "−";
}

.calc-faq-item p {
  margin: -2px 4px 15px;
  color: #5a6479;
  font-size: .83rem;
  line-height: 1.65;
}

@media (max-width: 520px) {
  .calc-help-button {
    width: 22px;
    height: 22px;
    min-width: 22px;
  }

  .calc-live-update {
    align-items: flex-start;
  }

  .calc-learning-card > summary {
    padding: 17px;
  }

  .calc-learning-content,
  .calc-faq-list {
    padding-left: 17px;
    padding-right: 17px;
  }

  .calc-formula {
    text-align: left;
    font-size: .82rem;
  }
}
