/* ==========================================================================
   CredGuide - EMI and eligibility calculator
   Every class starts with "cg-" so nothing here clashes with the site's CSS.
   Sections: 1 tokens, 2 page shell, 3 calculator, 4 schedule and tables,
             5 notes, CTA and footer, 6 wider screens, 7 print.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --cg-navy: #13295E;
  --cg-navy-deep: #0C1B42;
  --cg-blue: #2F52A8;        /* principal in charts */
  --cg-gold: #C4901C;        /* brand gold, used as a fill */
  --cg-gold-chart: #B8860B;  /* interest in charts */
  --cg-gold-light: #F3C552;  /* gold on navy */
  --cg-gold-text: #7F5B05;   /* gold as text on white */
  --cg-green: #2B7A39;
  --cg-slate: #5A6578;
  --cg-ink: #14213F;
  --cg-muted: #55607A;
  --cg-line: #D7DEEB;
  --cg-page: #F4F6FB;
  --cg-card: #FFFFFF;
  --cg-cream: #FBF4E2;
  --cg-tint: #ECF1FA;
  --cg-font: "Anek Latin", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 2. Page shell ------------------------------------------------------------ */
body { margin: 0; }

.cg-page {
  font-family: var(--cg-font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--cg-ink);
  background: var(--cg-page);
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
}
.cg-page *, .cg-page *::before, .cg-page *::after { box-sizing: border-box; }
.cg-page [hidden] { display: none !important; }
.cg-page p { margin: 0; }
.cg-page a { color: var(--cg-navy); }
.cg-page :focus-visible { outline: 3px solid var(--cg-gold); outline-offset: 2px; }

.cg-wrap { max-width: 1120px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.cg-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Headings share the tall, narrow cut of the CredGuide flyer headline */
.cg-page h1, .cg-page h2 {
  margin: 0;
  font-weight: 700;
  font-stretch: 75%;
  line-height: 1.05;
  color: var(--cg-navy);
  text-wrap: balance;
}
.cg-page h1 { font-size: clamp(2.25rem, 1.5rem + 3.6vw, 3.75rem); }
.cg-page h2 { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.375rem); }
.cg-page h3 { margin: 0 0 8px; font-size: 1.1875rem; font-weight: 600; line-height: 1.25; color: var(--cg-navy); }

/* Header */
.cg-header { background: var(--cg-card); border-bottom: 1px solid var(--cg-line); }
.cg-header-in { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.cg-logo { display: inline-flex; align-items: center; margin-right: auto; text-decoration: none; }
.cg-logo img { display: block; height: 40px; width: auto; max-width: 180px; }
.cg-logo-text { font-size: 1.875rem; font-weight: 700; line-height: 1; letter-spacing: -0.01em; color: var(--cg-navy); }
.cg-logo-text span { color: var(--cg-gold); }
.cg-nav { display: none; gap: 28px; }
.cg-nav a { font-weight: 500; text-decoration: none; }
.cg-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* Buttons */
.cg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1.5px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer;
}
.cg-page a.cg-btn--gold, .cg-btn--gold { background: var(--cg-gold); color: var(--cg-navy-deep); }
.cg-btn--gold:hover { background: #D5A22E; }
.cg-page a.cg-btn--navy, .cg-btn--navy { background: var(--cg-navy); color: #fff; }
.cg-btn--navy:hover { background: var(--cg-navy-deep); }
.cg-page a.cg-btn--line, .cg-btn--line { background: var(--cg-card); border-color: var(--cg-navy); color: var(--cg-navy); }
.cg-btn--line:hover { background: var(--cg-tint); }
.cg-page a.cg-btn--ghost, .cg-btn--ghost { border-color: rgba(255, 255, 255, 0.7); color: #fff; }
.cg-btn--ghost:hover { background: rgba(255, 255, 255, 0.12); }
.cg-btn--small { min-height: 40px; padding: 0 14px; font-size: 0.9375rem; }
.cg-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.cg-header-call { min-height: 44px; padding: 0 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Intro */
.cg-main { padding-top: 28px; padding-bottom: 56px; }
.cg-intro p { max-width: 38em; margin-top: 12px; font-size: 1.125rem; color: var(--cg-muted); }

/* 3. Calculator ------------------------------------------------------------ */
.cg-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  max-width: 520px; margin-top: 24px; padding: 4px;
  background: var(--cg-card); border: 1px solid var(--cg-line); border-radius: 999px;
}
.cg-tab {
  min-height: 48px; padding: 6px 12px;
  border: 0; border-radius: 999px; background: transparent;
  font: inherit; font-weight: 600; line-height: 1.15; color: var(--cg-navy);
  cursor: pointer;
}
.cg-tab:hover { background: var(--cg-tint); }
.cg-tab[aria-selected="true"] { background: var(--cg-navy); color: #fff; }

.cg-calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "figure" "inputs" "detail";
  margin-top: 16px;
  background: var(--cg-card);
  border: 1px solid var(--cg-line);
  border-radius: 16px;
}

/* The answer. On phones it stays pinned while the sliders below are moved. */
.cg-figure {
  grid-area: figure;
  position: sticky; top: 0; z-index: 3;
  padding: 14px 20px 16px;
  background: var(--cg-navy);
  color: #fff;
  border-radius: 15px 15px 0 0;
}
.cg-figure-label { font-size: 1rem; font-weight: 500; color: rgba(255, 255, 255, 0.82); }
.cg-figure-value {
  font-size: clamp(2.875rem, 1.9rem + 4.6vw, 4.75rem);
  font-weight: 700; font-stretch: 75%; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--cg-gold-light);
  white-space: nowrap;
}
.cg-page .cg-figure-value { margin: 4px 0 2px; }
.cg-figure-sub { font-size: 0.9375rem; color: rgba(255, 255, 255, 0.82); }

.cg-inputs { grid-area: inputs; padding: 4px 20px 8px; min-width: 0; }
.cg-detail { grid-area: detail; padding: 20px; border-top: 1px solid var(--cg-line); min-width: 0; }
.cg-page .cg-detail-title {
  margin-bottom: 12px;
  font-size: 1.1875rem; font-weight: 600; font-stretch: 100%; line-height: 1.25;
}

/* Fields */
.cg-field { padding: 18px 0; border-top: 1px solid var(--cg-line); }
.cg-field:first-child { border-top: 0; }
.cg-field-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cg-field-head > div:first-child { min-width: 0; }
.cg-label { display: block; font-weight: 600; line-height: 1.3; }
.cg-note { font-size: 0.9375rem; line-height: 1.35; color: var(--cg-muted); }
.cg-page .cg-note { margin-top: 2px; }
.cg-note.is-flag { color: var(--cg-gold-text); font-weight: 500; }

.cg-box {
  flex: none; display: flex; align-items: center; gap: 4px;
  width: 10.5rem; height: 48px; padding: 0 12px;
  background: var(--cg-card); border: 1.5px solid #AEB9CE; border-radius: 8px;
}
.cg-box--short { width: 5.5rem; }
.cg-box:focus-within { border-color: var(--cg-navy); box-shadow: 0 0 0 3px rgba(47, 82, 168, 0.25); }
.cg-box input {
  width: 100%; min-width: 0; padding: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 1.1875rem; font-weight: 600; color: var(--cg-ink);
  font-variant-numeric: tabular-nums; text-align: right;
}
.cg-affix { font-weight: 600; color: var(--cg-muted); }

.cg-tenure { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* Two-way switch (years or months, yearly or monthly) */
.cg-seg { display: inline-flex; padding: 3px; background: var(--cg-tint); border-radius: 8px; }
.cg-seg button {
  min-height: 34px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent;
  font: inherit; font-size: 0.9375rem; font-weight: 600; color: var(--cg-muted);
  cursor: pointer;
}
.cg-seg button[aria-pressed="true"] { background: var(--cg-card); color: var(--cg-navy); box-shadow: 0 1px 2px rgba(12, 27, 66, 0.2); }

/* Sliders */
.cg-range {
  --pct: 50%;
  display: block; width: 100%; height: 32px; margin: 8px 0 0; padding: 0;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.cg-range:focus { outline: none; }
.cg-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--cg-navy) var(--pct), #CFD7E6 var(--pct));
}
.cg-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -10px;
  border: 3px solid #fff; border-radius: 50%;
  background: var(--cg-gold);
  box-shadow: 0 0 0 1px var(--cg-navy), 0 2px 5px rgba(12, 27, 66, 0.35);
}
.cg-range::-moz-range-track { height: 6px; border-radius: 3px; background: #CFD7E6; }
.cg-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--cg-navy); }
.cg-range::-moz-range-thumb {
  width: 20px; height: 20px;
  border: 3px solid #fff; border-radius: 50%;
  background: var(--cg-gold);
  box-shadow: 0 0 0 1px var(--cg-navy), 0 2px 5px rgba(12, 27, 66, 0.35);
}
.cg-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--cg-navy), 0 0 0 5px rgba(196, 144, 28, 0.45); }
.cg-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--cg-navy), 0 0 0 5px rgba(196, 144, 28, 0.45); }
.cg-range-ends { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--cg-muted); }

/* Principal and interest split */
.cg-split { display: flex; gap: 2px; height: 28px; }
.cg-split span {
  flex: 1 1 0; min-width: 6px; overflow: hidden;
  display: flex; align-items: center; padding-left: 8px;
  border-radius: 4px;
  font-size: 0.9375rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.cg-split-p { background: var(--cg-blue); color: #fff; }
.cg-split-i { background: var(--cg-gold-chart); color: var(--cg-navy-deep); }
.cg-split span.is-thin { padding-left: 0; font-size: 0; }

.cg-key { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.cg-key--p { background: var(--cg-blue); }
.cg-key--i { background: var(--cg-gold-chart); }

.cg-stats { margin: 10px 0 0; }
.cg-stats > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--cg-line);
}
.cg-stats dt { display: flex; align-items: center; gap: 8px; color: var(--cg-muted); }
.cg-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cg-stats .cg-stats-total { border-bottom: 0; }
.cg-stats .cg-stats-total dt { color: var(--cg-ink); font-weight: 600; }
.cg-stats .cg-stats-total dd { font-size: 1.3125rem; font-weight: 700; color: var(--cg-navy); }

.cg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.cg-actions .cg-btn { flex: 1 1 13rem; }

/* EMI by repayment period (salary tab) */
.cg-mini { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cg-mini th, .cg-mini td { padding: 10px 0 10px 12px; text-align: right; border-bottom: 1px solid var(--cg-line); }
.cg-mini th:first-child, .cg-mini td:first-child { padding-left: 0; text-align: left; }
.cg-mini thead th { padding-top: 0; font-size: 0.9375rem; font-weight: 500; color: var(--cg-muted); }
.cg-mini tbody th { font-weight: 500; }
.cg-mini td.cg-emi { font-weight: 700; color: var(--cg-navy); }
.cg-mini .cg-tag { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--cg-gold-text); }
.cg-small { font-size: 0.9375rem; color: var(--cg-muted); }
.cg-page .cg-small { margin-top: 12px; }

/* 4. Schedule and tables --------------------------------------------------- */
.cg-section { margin-top: 44px; }
.cg-lede { max-width: 40em; color: var(--cg-muted); }
.cg-page .cg-lede { margin-top: 8px; }

.cg-chartcard {
  margin: 18px 0 0; padding: 16px 12px 12px;
  background: var(--cg-card); border: 1px solid var(--cg-line); border-radius: 16px;
}
.cg-chartcard figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 0 4px 10px; }
.cg-chart-title { font-weight: 600; }
.cg-legend { display: inline-flex; gap: 16px; font-size: 0.9375rem; color: var(--cg-muted); }
.cg-legend > span { display: inline-flex; align-items: center; gap: 6px; }

.cg-chart { position: relative; height: 220px; border-radius: 8px; }
.cg-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cg-chart .cg-grid { stroke: #E4E9F2; stroke-width: 1; }
.cg-chart .cg-base { stroke: #B9C3D6; stroke-width: 1; }
.cg-chart text { font-family: var(--cg-font); font-size: 12px; fill: var(--cg-muted); font-variant-numeric: tabular-nums; }
.cg-chart .cg-bar-p { fill: var(--cg-blue); }
.cg-chart .cg-bar-i { fill: var(--cg-gold-chart); }
.cg-chart .cg-hit { fill: transparent; }
.cg-chart svg.has-active .cg-col { opacity: 0.5; }
.cg-chart svg.has-active .cg-col.is-active { opacity: 1; }
.cg-axis-title { font-size: 0.875rem; color: var(--cg-muted); text-align: center; }

.cg-tip {
  position: absolute; z-index: 4; pointer-events: none;
  min-width: 11.5rem; padding: 10px 12px;
  background: var(--cg-navy-deep); color: #fff; border-radius: 8px;
  font-size: 0.875rem; line-height: 1.3;
  box-shadow: 0 6px 18px rgba(12, 27, 66, 0.28);
}
.cg-tip-h { margin-bottom: 6px; font-weight: 600; }
.cg-tip-r { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.cg-tip-r i { flex: none; width: 12px; height: 3px; border-radius: 2px; background: transparent; }
.cg-tip-r i.is-p { background: #8FA9EA; }
.cg-tip-r i.is-i { background: var(--cg-gold-light); }
.cg-tip-r b { font-weight: 700; font-variant-numeric: tabular-nums; }
.cg-tip-r span { margin-left: auto; color: rgba(255, 255, 255, 0.78); }

.cg-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }

.cg-table-wrap {
  margin-top: 12px; overflow-x: auto;
  background: var(--cg-card); border: 1px solid var(--cg-line); border-radius: 16px;
}
.cg-table-wrap.is-long { max-height: 31rem; overflow-y: auto; }
.cg-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.cg-table th, .cg-table td { padding: 10px 12px; text-align: right; white-space: nowrap; }
.cg-table th:first-child, .cg-table td:first-child { text-align: left; }
.cg-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--cg-navy); color: #fff;
  font-weight: 600; line-height: 1.2; white-space: normal; vertical-align: bottom;
}
.cg-table tbody th { font-weight: 500; }
.cg-table tbody tr:nth-child(even) { background: #F6F8FC; }
.cg-table tfoot th, .cg-table tfoot td { border-top: 2px solid var(--cg-navy); font-weight: 700; color: var(--cg-navy); }

/* The salary guide keeps the flyer's four column colours */
.cg-table--guide thead th { position: static; }
.cg-table--guide thead th:nth-child(2) { background: var(--cg-slate); }
.cg-table--guide thead th:nth-child(3) { background: var(--cg-green); }
.cg-table--guide thead th:nth-child(4) { background: var(--cg-gold); color: var(--cg-navy-deep); }
.cg-table--guide tbody tr:nth-child(even) { background: transparent; }
.cg-table--guide tbody th, .cg-table--guide tbody td { border-top: 1px solid var(--cg-line); font-weight: 600; }
.cg-table--guide tbody th { background: var(--cg-tint); }
.cg-table--guide tbody td:last-child { background: var(--cg-cream); }

/* 5. Notes, CTA and footer ------------------------------------------------- */
.cg-how-grid { display: grid; gap: 28px; margin-top: 18px; }
.cg-how-grid p { max-width: 36em; }
.cg-how-grid p + p { margin-top: 10px; }
.cg-formula {
  padding: 12px 14px;
  background: var(--cg-card); border: 1px solid var(--cg-line); border-radius: 8px;
  font-size: 1.125rem; font-weight: 600; color: var(--cg-navy);
}
.cg-formula sup { font-size: 0.7em; }
.cg-disclaimer {
  padding: 14px 16px;
  background: var(--cg-cream); border: 1px solid #E8D6A6; border-radius: 12px;
  font-size: 0.9375rem; color: #4D4222;
}
.cg-page .cg-disclaimer { margin-top: 28px; }

.cg-cta {
  display: grid; gap: 20px; margin-top: 44px; padding: 28px 20px;
  background: var(--cg-navy); color: #fff; border-radius: 16px;
}
.cg-page .cg-cta h2 { color: #fff; }
.cg-cta p { color: rgba(255, 255, 255, 0.82); }
.cg-page .cg-cta p { margin-top: 8px; }
.cg-cta-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cg-cta-actions .cg-btn { flex: 1 1 12rem; }

.cg-footer { border-top: 1px solid var(--cg-line); background: var(--cg-card); font-size: 0.9375rem; color: var(--cg-muted); }
.cg-footer-in { display: grid; gap: 16px; padding-top: 24px; padding-bottom: 28px; }
.cg-footer strong { color: var(--cg-navy); }
.cg-footer a { text-underline-offset: 3px; }

/* Very small phones */
@media (max-width: 359px) {
  .cg-logo-text { font-size: 1.5rem; }
  .cg-logo img { height: 32px; max-width: 130px; }
  .cg-header-call { padding: 0 10px; font-size: 0.9375rem; }
  .cg-inputs, .cg-detail { padding-left: 14px; padding-right: 14px; }
  .cg-figure { padding-left: 14px; padding-right: 14px; }
  .cg-box { width: 9.25rem; }
  .cg-box--short { width: 5rem; }
  .cg-table { font-size: 0.8125rem; }
  .cg-table th, .cg-table td { padding: 9px 6px; }
}

/* 6. Wider screens --------------------------------------------------------- */
@media (min-width: 600px) {
  .cg-wrap { padding-left: 24px; padding-right: 24px; }
  .cg-nav { display: flex; }
  .cg-header-call { margin-left: 8px; }
  .cg-tenure { flex-direction: row-reverse; align-items: center; }
  .cg-chartcard { padding: 20px 20px 14px; }
  .cg-chart { height: 260px; }
  .cg-table th, .cg-table td { padding: 12px 20px; }
  .cg-table { font-size: 1rem; }
  .cg-how-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
  .cg-footer-in { grid-template-columns: 1.6fr 1fr 1fr; }
  .cg-copy { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .cg-main { padding-top: 44px; padding-bottom: 72px; }
  .cg-calc {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "inputs figure" "inputs detail";
  }
  .cg-figure { position: static; padding: 28px 32px; border-radius: 0 15px 0 0; }
  .cg-inputs { padding: 14px 32px 16px; }
  .cg-detail { padding: 24px 32px 28px; border-top: 0; border-left: 1px solid var(--cg-line); }
  .cg-field { padding: 22px 0; }
  .cg-box { width: 11.5rem; }
  .cg-box--short { width: 6rem; }
  .cg-cta { grid-template-columns: 1fr auto; align-items: center; padding: 36px 40px; }
  .cg-cta-actions .cg-btn { flex: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .cg-split span { transition: flex-grow 0.18s ease-out; }
}

/* 7. Print: the result and the schedule only ------------------------------- */
@media print {
  .cg-page { background: #fff; font-size: 11pt; }
  .cg-noprint, .cg-nav, .cg-header-call, .cg-tabs, .cg-range, .cg-range-ends, .cg-seg, .cg-tools, .cg-how > h2, .cg-how-grid, .cg-chartcard { display: none !important; }
  .cg-figure { position: static; }
  .cg-figure, .cg-split-p, .cg-split-i, .cg-key, .cg-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cg-table-wrap, .cg-table-wrap.is-long { max-height: none; overflow: visible; border: 0; }
  .cg-table thead th { position: static; }
  .cg-section { margin-top: 20px; }
}
