/* ── RESET & BASE ─────────────────────────── */
:root {
  --primary: #0d5487;
  --primary-light: #1a6fa8;
  --primary-dark: #093d63;
  --bg: #f4f7fb;
  --card: #fff;
  --border: #dde3ed;
  --text: #1a2332;
  --text2: #4a5568;
  --text3: #8a96a8;
  --shadow: 0 2px 12px rgba(13,84,135,0.10);
  --radius: 10px;
  --c-principal: #4caf50;
  --c-interest: #ff9800;
  --red: #b12e38;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* FIX #5: removed overflow-x:hidden from html/body — it masks not fixes */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Lato", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Prevent any child from creating horizontal scroll */
  max-width: 100vw;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6{
    font-family: "Golos Text", sans-serif;
    font-weight: 500;
}

p, span, a{
    font-family: "Lato", sans-serif;
    font-weight: 400;
}

a{
    text-decoration: none;
}

/* ── Header LAYOUT ─────────────────────────── */
/* Container */

.sp-container{
    width:100%;
    max-width:1280px;
    margin:auto;
    padding:0 20px;
}

/* HEADER */

.sp-header{

    background:#fff;
    position:sticky;
    top:0;
    z-index:99;
    box-shadow:
    0 10px 25px rgba(0,0,0,.05);
}

.sp-header .sp-container{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:85px;
}

.sp-logo{
    max-width: 250px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sp-logo img{
    width: 50px;
}

.sp-logo-txt{
    font-size: 24px;
    color: var(--primary);
}

.sp-logo-txt .small-font {
    font-size: 10px;
    top: -10px;
}


.sp-header-btn{
    position:relative;
    overflow:hidden;
    background: var(--primary);
    color:#fff;
    padding:14px 28px;
    border-radius:50px;
    text-decoration:none;
    transition:.4s;
}

.sp-header-btn::before{

    content:'';

    position:absolute;

    top:0;
    left:-100%;

    width:100%;
    height:100%;

    background:
    linear-gradient(
    120deg,
    transparent,
    rgba(255,255,255,.25),
    transparent
    );

    transition:.7s;
}

.sp-header-btn:hover{

    transform:translateY(-4px);

    box-shadow:
    0 15px 35px rgba(13,84,135,.35);
}

.sp-header-btn:hover::before{

    left:120%;
}

.sp-header-btn i{

    transition:.4s;
}

.sp-header-btn:hover i{

    transform:translateX(2px);
}


.sp_main-title{
  margin: 40px 0 20px;
}

.sp_main-title h1{
  font-size: 36px;
}



/* ── MAIN LAYOUT ─────────────────────────── */
.main-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  align-items: start;
  /* FIX: ensure main wrap never exceeds viewport */
  width: 100%;
  overflow: hidden;
}

/* ── CARDS ───────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  /* FIX #1 support: card must never exceed its grid column */
  width: 100%;
  min-width: 0;
  overflow: hidden;
}
.card-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 18px;
  font-weight: 600;
}
.card-header > img{
  max-width: 22px;
  margin-right: 4px;
}
.calc-section {
  padding: 16px;
  /* FIX #1 support: section must not overflow card */
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* ── SLIDERS ─────────────────────────────── */
.slider-group { margin-bottom: 18px; }

.slider-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}
.slider-top label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  flex: 1;
  min-width: 100px;
}

.slider-input-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  /* FIX #2: cap width so it never overflows */
  max-width: 160px;
}
.slider-prefix {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: #e8f0f8;
  padding: 0 8px;
  border: 1px solid var(--border); border-right: none;
  border-radius: 5px 0 0 5px;
  height: 34px;
  display: flex; align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}
/* FIX #2: was fixed width:110px — now flexible */
.slider-input {
  flex: 1;
  min-width: 50px;
  max-width: 110px;
  border: 1px solid var(--border);
  border-radius: 0 5px 5px 0;
  padding: 0 8px;
  font-size: 13px;
  font-family: 'Lato', sans-serif;
  color: var(--text);
  background: #fff;
  height: 34px;
  outline: none;
}
.slider-input:focus { border-color: var(--primary); }

.tenure-wrap { display: flex; }
.tenure-input { width: 60px; min-width: 40px; border-radius: 0; border-right: none; max-width: 60px; }
.tenure-unit {
  width: 52px;
  border: 1px solid var(--border);
  border-radius: 0 5px 5px 0;
  padding: 0 4px;
  font-size: 12px;
  font-family: 'Lato', sans-serif;
  color: var(--text);
  background: #fff;
  height: 34px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  max-width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary) 50%, #d0dae8 50%);
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
  display: block;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(13,84,135,0.3);
  border: 2px solid #fff;
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
}
.slider-marks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  width: 100%;
}
.slider-marks span { font-size: 10px; color: var(--text3); }

/* ── RESULTS GRID ────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  min-width: 0;
}
.result-left {
  padding: 16px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.result-item { margin-bottom: 16px; }
.result-item:last-child { margin-bottom: 0; }
.r-label { font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; line-height: 1.4; }
.r-value { font-size: 20px; font-weight: 700; color: var(--primary); word-break: break-word; }
.result-item.highlight .r-label { color: #c0392b; }
.result-item.highlight .r-value { color: #c0392b; }

.result-right {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.pie-title { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 12px; text-align: center; }
.pie-wrap { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.pie-wrap canvas { width: 100% !important; height: 100% !important; }
.pie-legend { margin-top: 10px; width: 100%; min-width: 0; }
.pie-legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text2); margin-bottom: 5px;
}
.pie-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.pie-legend-item span:last-child { margin-left: auto; font-weight: 600; color: var(--text); }

/* ── SCHEDULE CONTROLS ───────────────────── */
.schedule-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #f0f5fb;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  min-width: 0;
}
.schedule-header label {
  font-size: 13px; font-weight: 500; color: var(--text2); white-space: nowrap;
  width: 100%;
}
.sch-date {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: 'Lato', sans-serif;
  color: var(--text);
  background: #fff;
  outline: none;
  height: 36px;
  cursor: pointer;
  /* FIX #3: no fixed min-width, let it flex */
  flex: 1;
  min-width: 0;
  max-width: 180px;
}
.sch-date:focus { border-color: var(--primary); }

/* FIX #3: was min-width:170px — removed, now flexible */
.sch-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: 'Lato', sans-serif;
  color: var(--text);
  background: #fff;
  outline: none;
  height: 36px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  max-width: 200px;
}
.sch-select:focus { border-color: var(--primary); }

/* ── BAR CHART ───────────────────────────── */
.bar-chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  margin-bottom: 8px;
  /* FIX: chart canvas must never overflow */
  overflow: hidden;
}
.chart-legend {
  display: flex; gap: 18px; justify-content: center;
  padding: 8px 0 16px; flex-wrap: wrap;
}
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-line { width: 22px; height: 3px; border-radius: 2px; position: relative; flex-shrink: 0; }
.legend-line::before {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff;
}

/* ── EMI TABLE ───────────────────────────── */
.emi-table-wrap {
  /* FIX #1: this wrapper MUST scroll, not let table push layout */
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  /* Critical: this creates a new block formatting context */
  display: block;
}
/* FIX #1: min-width stays so table is readable when scrolled,
   but the WRAPPER clips it — not the page */
.emi-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 580px; }
.emi-table thead tr { background: var(--primary); color: #fff; }
/* FIX #6: removed white-space:nowrap from th — was locking column widths */
.emi-table th {
  padding: 10px 10px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
}
.emi-table th:first-child { text-align: left; }
.emi-table td { padding: 9px 10px; text-align: right; border-bottom: 1px solid #edf2f8; color: var(--text2); }
.emi-table td:first-child { text-align: left; }
.emi-table tbody tr:hover { background: #f0f5fb; }

.yr-row td { font-weight: 600; color: var(--text); background: #f7fafd; cursor: pointer; }
.yr-row td:first-child { color: var(--primary); }
.yr-row:hover td { background: #edf4fb; }
.yr-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 3px;
  background: var(--primary); color: #fff; font-size: 11px;
  margin-right: 6px; font-weight: 700; transition: transform 0.2s;
  flex-shrink: 0; line-height: 1;
}
.yr-row.open .yr-toggle { transform: rotate(90deg); }
.mo-row { display: none; }
.mo-row.visible { display: table-row; }
.mo-row td { background: #fff; color: var(--text2); font-weight: 400; font-size: 11.5px; }
.mo-row td:first-child { padding-left: 36px; color: var(--text2); }
.total-row td { font-weight: 700; background: #dbeaf6; color: var(--primary); border-bottom: none; }
.total-row td:first-child { color: var(--primary); }

/* ── ACTION BUTTONS ──────────────────────── */
.action-btns { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 0 4px; }
.act-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: 6px;
  font-size: 13px; font-family: 'Lato', sans-serif; font-weight: 500;
  cursor: pointer; border: 1.5px solid var(--primary);
  background: #fff; color: var(--primary);
  transition: all 0.18s; white-space: nowrap;
}
.act-btn:hover { background: var(--primary); color: #fff; }
.act-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.share-link-box { margin-top: 12px; display: none; width: 100%; }
.share-link-box.visible { display: flex; }
.share-link-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 6px 0 0 6px;
  padding: 7px 10px; font-size: 12px;
  font-family: 'Lato', sans-serif; color: var(--text2);
  background: #f9fbfd; outline: none;
}
.copy-btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 0 6px 6px 0; padding: 7px 14px;
  font-size: 12px; font-family: 'Lato', sans-serif;
  cursor: pointer; font-weight: 500; white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--primary-dark); }

/* ── SIDEBAR ─────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* FIX #7: sidebar cards need padding — applied via CSS not inline HTML */
.sidebar .card { padding: 16px; min-width: 0; }

.sidebar-section-title {
  font-size: 12px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}
.service-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 13px; margin-bottom: 8px;
  background: var(--primary); color: #fff; border: none; border-radius: 7px;
  font-size: 13px; font-family: 'Lato', sans-serif; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background 0.15s, transform 0.1s; line-height: 1.4;
  min-width: 0;
}
.service-btn:hover { background: var(--primary-light); transform: translateX(2px); }
.service-btn:last-child { margin-bottom: 0; }
.service-btn span { min-width: 0; flex: 1; line-height: 1.8; }
.service-btn .chevron { flex-shrink: 0; margin-left: 8px; }
.badge-free {
  display: inline-block;
  font-size: 11px; background: #ffffff; color: var(--primary);
  padding: 2px 12px; border-radius: 20px; margin-left: 6px;
  font-weight: 600; white-space: nowrap;
  animation: waggle 2s linear infinite;
}
.badge-mh {
  font-size: 10px; background: rgba(255,255,255,0.25); color: #fff;
  padding: 2px 6px; border-radius: 10px; margin-left: 6px;
  white-space: nowrap;
}

/*-------------------------- Animation Css  --------------------------*/


@keyframes waggle{
  0%{
    transform: scale(1);
  }
  25%{
    transform: scale(1.2);
  }
  50%{
    transform: scale(1);
  }
  75%{
    transform: scale(1.2);
  }
  100%{
    transform: scale(1);
  }
}

/* ── MODAL ───────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(10,30,60,0.55);
  z-index: 1000; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 520px;
  box-shadow: 0 8px 40px rgba(13,84,135,0.25);
  overflow: hidden; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header {
  background: var(--primary); color: #fff;
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; line-height: 1.3; }
.modal-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1; opacity: 0.8; padding: 0 2px;
  flex-shrink: 0;
}
.modal-close:hover { opacity: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); }
.form-group input, .form-group select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; font-size: 13px;
  font-family: 'Lato', sans-serif; color: var(--text);
  background: #fff; outline: none;
  width: 100%; min-width: 0;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13,84,135,0.1);
}
.form-product { font-size: 12px; color: var(--text3); margin-bottom: 14px; font-style: italic; }
.modal-footer {
  padding: 14px 20px; background: #f4f7fb;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}
.btn-submit {
  background: var(--primary); color: #fff; border: none;
  border-radius: 6px; padding: 10px 24px;
  font-size: 13px; font-family: 'Lato', sans-serif; font-weight: 600; cursor: pointer;
}
.btn-submit:hover { background: var(--primary-dark); }
.btn-cancel {
  background: #fff; color: var(--text2);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 18px;
  font-size: 13px; font-family: 'Lato', sans-serif; cursor: pointer;
}
.success-msg { display: none; text-align: center; padding: 20px; }
.success-msg.show { display: block; }
.success-icon { font-size: 40px; margin-bottom: 10px; }

/* ── FOOTER ──────────────────────────────── */
.site-footer {
  background: var(--primary-dark); color: rgba(255,255,255,0.7);
  text-align: center; padding: 14px 16px; font-size: 14px;
  margin-top: 16px; line-height: 1.5;
  width: 100%;
}

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #222; color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; z-index: 9999;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
  max-width: calc(100vw - 48px);
}
.toast.show { opacity: 1; }





/* ════════════════════════════════════════════
   TABLET  ≤ 960px
═══════════════════════════════════════════ */
@media (max-width: 960px) {
  .main-wrap {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 16px;
  }

  /* FIX #4: was min-width:260px — reduced so two cards fit comfortably */
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
  }
  .sidebar .card { flex: 1 1 200px; min-width: 0; }

  .bar-chart-wrap { height: 260px; }

  .sch-date { max-width: 160px; }
  .sch-select { max-width: 180px; }
}

/* ════════════════════════════════════════════
   MOBILE  ≤ 640px
═══════════════════════════════════════════ */
@media (max-width: 640px) {

    .sp-logo img{
        width: 35px;
    }
    .sp-logo-txt{
        font-size: 16px;
    }
    .sp-logo-txt .small-font{
        font-size: 11px;
    }
    .sp_main-title h1{
      font-size: 24px;
    }
    .sp-header-btn{
      padding:8px 18px;
      font-size: 14px;
    }
    .sp-header .sp-container{
      padding: 0 10px;
    }
  .main-wrap { padding: 10px; gap: 12px; }
  .calc-section { padding: 12px; }

  .site-header h1 { font-size: 14px; }
  .site-header p  { font-size: 10px; }

  /* Sliders: label full width, input below it */
  .slider-top { flex-direction: column; align-items: flex-start; gap: 6px; }
  .slider-input-wrap { width: 100%; max-width: 100%; }
  .slider-input { flex: 1; max-width: 100%; }

  /* Results stack */
  .results-grid { grid-template-columns: 1fr; }
  .result-left { border-right: none; border-bottom: 1px solid var(--border); }
  .result-right { padding: 14px 16px; }
  .pie-wrap { width: 120px; height: 120px; }
  .r-value { font-size: 18px; }

  /* Schedule controls full width */
  .schedule-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .schedule-header label { width: 100%; }
  .sch-date, .sch-select { width: 100%; max-width: 100%; flex: none; }

  /* Shorter chart */
  .bar-chart-wrap { height: 200px; }

  /* Table: slightly more compact */
  .emi-table { font-size: 11px; min-width: 520px; }
  .emi-table th, .emi-table td { padding: 8px 7px; }

  /* Buttons full width */
  .action-btns { flex-direction: column; gap: 8px; }
  .act-btn { width: 100%; }

  /* Sidebar full width single column */
  .sidebar { flex-direction: column; }
  .sidebar .card { flex: none; width: 100%; min-width: 0; }

  /* Modal */
  .form-row { grid-template-columns: 1fr; }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .btn-submit, .btn-cancel { width: 100%; text-align: center; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-header h3 { font-size: 14px; }

  /* Toast full width */
  .toast { left: 12px; right: 12px; bottom: 16px; text-align: center; max-width: unset; }
}

/* ════════════════════════════════════════════
   SMALL MOBILE  ≤ 380px
═══════════════════════════════════════════ */
@media (max-width: 380px) {
  .main-wrap { padding: 8px; }
  .calc-section { padding: 10px; }
  .logo-mark { width: 34px; height: 34px; min-width: 34px; font-size: 14px; }
  .site-header { padding: 10px 12px; gap: 10px; }
  .site-header h1 { font-size: 13px; }
  .r-value { font-size: 16px; }
  .bar-chart-wrap { height: 170px; }
  .slider-marks span { font-size: 9px; }
  .pie-wrap { width: 100px; height: 100px; }
  .emi-table { font-size: 10.5px; min-width: 480px; }
  .emi-table th, .emi-table td { padding: 7px 5px; }
}

/* ── FORM VALIDATION ADDITIONS ─────────────────────────────── */
.req-star { color: #d32f2f; }
.field-err {
  display: block;
  font-size: 11px;
  color: #d32f2f;
  margin-top: 3px;
  min-height: 14px;
  line-height: 1.3;
}
.form-group input.error,
.form-group select.error {
  border-color: #d32f2f;
  box-shadow: 0 0 0 2px rgba(211,47,47,0.12);
}
