/* ============================================
   ZAMBIA LOAN APP — FULLY RESPONSIVE
   Fluid design: 320px phones → 4K displays
   ============================================ */

:root {
    /* Safaricom colors */
    --safaricom-green: #00A94F;
    --safaricom-green-dark: #007A3A;
    --safaricom-green-light: #E8F7EE;
    --safaricom-green-hover: #008F43;

    /* Neutrals */
    --white: #ffffff;
    --off-white: #fafbfa;
    --gray-50: #f6f8f7;
    --gray-100: #eef2f0;
    --gray-200: #dde4e0;
    --gray-300: #c5ccc8;
    --gray-400: #9aa39e;
    --gray-600: #5a635d;
    --gray-800: #2a302d;
    --text: #1f2421;
    --red: #d63333;
    --yellow: #f5a623;

    /* Fluid type scale — scales smoothly from 320px to 1440px */
    --fs-xs:    clamp(0.70rem, 0.66rem + 0.18vw, 0.78rem);
    --fs-sm:    clamp(0.80rem, 0.76rem + 0.20vw, 0.88rem);
    --fs-base:  clamp(0.92rem, 0.88rem + 0.22vw, 1.02rem);
    --fs-md:    clamp(1.00rem, 0.94rem + 0.30vw, 1.15rem);
    --fs-lg:    clamp(1.15rem, 1.05rem + 0.50vw, 1.40rem);
    --fs-xl:    clamp(1.40rem, 1.20rem + 1.00vw, 1.90rem);
    --fs-2xl:   clamp(1.70rem, 1.40rem + 1.50vw, 2.50rem);

    /* Fluid spacing */
    --sp-xs:  clamp(0.35rem, 0.30rem + 0.25vw, 0.55rem);
    --sp-sm:  clamp(0.55rem, 0.48rem + 0.35vw, 0.80rem);
    --sp-md:  clamp(0.80rem, 0.70rem + 0.50vw, 1.20rem);
    --sp-lg:  clamp(1.10rem, 0.95rem + 0.75vw, 1.80rem);
    --sp-xl:  clamp(1.50rem, 1.25rem + 1.25vw, 2.50rem);

    /* Radii */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,169,79,0.18);

    /* Safe area */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Layout breakpoints (reference only — use @media directly) */
    --content-narrow: 560px;
    --content-wide: 1140px;
}

/* ===== RESET ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* momentum scrolling on iOS */
    scroll-padding-top: 80px; /* offset for sticky header when jumping to anchors */
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--white);
    color: var(--text);
    line-height: 1.55;
    font-size: var(--fs-base);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* Let scroll happen naturally; don't lock or block it */
    overscroll-behavior-x: none; /* only block horizontal bounce */
    -webkit-overflow-scrolling: touch;
}
a { color: var(--safaricom-green); text-decoration: none; }
a:hover { color: var(--safaricom-green-dark); }
img, svg { max-width: 100%; display: block; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; /* prevents iOS zoom */ }

/* ===== FLUID CONTAINER — adapts across all screens ===== */
.container {
    width: 100%;
    max-width: min(100%, 1140px);
    margin: 0 auto;
    padding-left:  clamp(16px, 4vw, 32px);
    padding-right: clamp(16px, 4vw, 32px);
}

/* Narrow container for forms & single-column content (readable on large screens) */
.container-narrow {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding-left:  clamp(16px, 4vw, 32px);
    padding-right: clamp(16px, 4vw, 32px);
}

/* ===== APP HEADER ===== */
.site-header {
    background: var(--white);
    padding-top: var(--safe-top);
    border-bottom: 1px solid var(--gray-100);
    position: relative; /* not sticky - let it scroll away naturally */
    z-index: 100;
}

/* Sticky header only on larger screens where space isn't tight */
@media (min-width: 768px) {
    .site-header {
        position: sticky;
        top: 0;
    }
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-sm) 0;
    min-height: 58px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: var(--fs-md);
    color: var(--text);
}
.logo-mark {
    width: clamp(32px, 8vw, 40px);
    height: clamp(32px, 8vw, 40px);
    border-radius: 10px;
    background: var(--safaricom-green);
    color: var(--white);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: var(--fs-md);
    box-shadow: 0 4px 10px rgba(0,169,79,0.3);
    flex-shrink: 0;
}
.top-nav { display: none; gap: 20px; }
.top-nav a {
    color: var(--gray-600);
    font-weight: 500;
    font-size: var(--fs-sm);
}
.top-nav a:hover { color: var(--safaricom-green); }

@media (min-width: 768px) {
    .top-nav { display: flex; }
}

/* ===== PROGRESS STEPPER ===== */
.stepper-wrap {
    background: var(--white);
    padding: var(--sp-sm) 0 var(--sp-md);
    border-bottom: 1px solid var(--gray-100);
}
.step-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-xs);
    color: var(--gray-600);
    margin-bottom: var(--sp-xs);
    font-weight: 500;
}
.step-info .step-title { color: var(--text); font-weight: 600; font-size: var(--fs-sm); }
.stepper {
    display: flex;
    gap: 5px;
    list-style: none;
}
.stepper li {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-200);
    transition: background .3s;
}
.stepper li.done,
.stepper li.active { background: var(--safaricom-green); }
.step-num, .step-label { display: none; }

/* ===== MAIN ===== */
.main-content {
    flex: 1;
    padding-top: var(--sp-md);
    padding-bottom: var(--sp-xl);
    width: 100%;
}

/* When a fixed bottom CTA exists, add extra bottom padding so nothing is hidden behind it */
body:has(.bottom-cta) .main-content {
    padding-bottom: calc(130px + var(--safe-bottom));
}
/* Taller bottom CTA (stacked buttons) needs even more space */
body:has(.bottom-cta-stack) .main-content {
    padding-bottom: calc(180px + var(--safe-bottom));
}

/* ===== HERO ===== */
.hero {
    background: linear-gradient(135deg, var(--safaricom-green) 0%, var(--safaricom-green-dark) 100%);
    color: var(--white);
    padding: var(--sp-lg) var(--sp-md);
    border-radius: var(--radius-xl);
    margin-bottom: var(--sp-lg);
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: clamp(150px, 30vw, 280px);
    height: clamp(150px, 30vw, 280px);
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}
.hero::after {
    content: '';
    position: absolute;
    bottom: -50%;
    left: -10%;
    width: clamp(120px, 25vw, 220px);
    height: clamp(120px, 25vw, 220px);
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}
.hero h1 {
    font-size: var(--fs-xl);
    font-weight: 800;
    margin-bottom: var(--sp-xs);
    letter-spacing: -0.3px;
    position: relative;
    line-height: 1.15;
}
.hero h1 span { opacity: 0.95; }
.hero p {
    font-size: var(--fs-sm);
    opacity: 0.92;
    position: relative;
    line-height: 1.45;
    max-width: 520px;
}
.hero-badges {
    display: flex;
    gap: var(--sp-xs);
    margin-top: var(--sp-md);
    flex-wrap: wrap;
    position: relative;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: var(--fs-xs);
    font-weight: 500;
}
.hero-badge::before { content: '✓'; font-size: 0.7em; font-weight: 700; }

/* Larger hero on desktop */
@media (min-width: 768px) {
    .hero { padding: var(--sp-xl) var(--sp-lg); }
    .hero p { font-size: var(--fs-base); }
}

/* ===== SECTION TITLE ===== */
.section-title { margin-bottom: var(--sp-md); }
.section-title h2 {
    font-size: var(--fs-lg);
    color: var(--text);
    font-weight: 700;
    margin-bottom: 2px;
}
.section-title p { color: var(--gray-600); font-size: var(--fs-sm); }

/* ===== LOAN GRID — truly fluid ===== */
.loan-grid {
    display: grid;
    /* Auto-fit: 2 cols on small, 3-4 on mid, 4 on large */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
    gap: clamp(10px, 2vw, 18px);
    margin-bottom: var(--sp-lg);
}
.loan-card {
    background: var(--white);
    border: 2px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: clamp(14px, 3vw, 22px) clamp(10px, 2.5vw, 16px);
    text-align: center;
    transition: all .2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.loan-card:hover {
    border-color: var(--safaricom-green);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.loan-card:active { transform: scale(0.97); }
.loan-card .tier {
    display: inline-block;
    background: var(--safaricom-green-light);
    color: var(--safaricom-green-dark);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-sm);
}
.loan-card .amount {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    word-break: break-word;
}
.loan-card .amount-sub {
    font-size: var(--fs-xs);
    color: var(--gray-400);
    margin-bottom: var(--sp-xs);
    font-weight: 500;
}
.loan-card .duration {
    font-size: var(--fs-xs);
    color: var(--gray-600);
    padding-top: var(--sp-xs);
    border-top: 1px dashed var(--gray-200);
    margin-top: var(--sp-xs);
    width: 100%;
}
.loan-card .card-fee {
    font-size: var(--fs-xs);
    color: var(--safaricom-green-dark);
    background: var(--safaricom-green-light);
    padding: 4px 8px;
    border-radius: 6px;
    margin-top: 6px;
    font-weight: 600;
    display: inline-block;
}
.loan-card form { width: 100%; margin-top: var(--sp-sm); }

/* ===== BUTTONS — with polished animations ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: clamp(12px, 2.5vw, 14px) clamp(18px, 4vw, 24px);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: var(--fs-sm);
    border: none;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    min-height: 48px;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    /* Smooth, snappy transition */
    transition:
        transform .15s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow .25s ease,
        background-color .2s ease,
        color .2s ease;
    will-change: transform;
    user-select: none;
}

/* Ripple effect layer */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255,255,255,0.5) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0);
    transition: transform .6s ease-out, opacity .6s ease-out;
    pointer-events: none;
}
.btn.ripple-active::after {
    opacity: 1;
    transform: scale(2.5);
    transition: transform .6s ease-out, opacity .6s ease-out;
}

.btn-primary {
    background: var(--safaricom-green);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(0,169,79,0.25);
}
.btn-primary:hover {
    background: var(--safaricom-green-hover);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,169,79,0.4);
}
.btn-primary:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 2px 6px rgba(0,169,79,0.3);
    transition-duration: .08s;
}

.btn-secondary {
    background: var(--gray-50);
    color: var(--text);
    border: 1px solid var(--gray-200);
}
.btn-secondary:hover {
    background: var(--gray-100);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.btn-secondary:active {
    transform: translateY(0) scale(0.97);
    transition-duration: .08s;
}

.btn-block { display: flex; width: 100%; }
.btn-lg {
    padding: clamp(14px, 3vw, 18px) clamp(22px, 5vw, 30px);
    font-size: var(--fs-base);
    min-height: 54px;
}

/* Focus ring for accessibility */
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--safaricom-green-light), 0 0 0 5px var(--safaricom-green);
}

.loan-card .btn {
    padding: clamp(8px, 1.8vw, 10px) 10px;
    font-size: var(--fs-xs);
    min-height: 38px;
}

/* Pulse animation on primary CTA to draw attention */
@keyframes subtle-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0,169,79,0.25); }
    50%      { box-shadow: 0 4px 20px rgba(0,169,79,0.5); }
}
.bottom-cta .btn-primary.btn-lg {
    animation: subtle-pulse 2.5s ease-in-out infinite;
}
.bottom-cta .btn-primary.btn-lg:hover,
.bottom-cta .btn-primary.btn-lg:active { animation: none; }

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .btn, .btn::after { transition: none; animation: none; }
    .bottom-cta .btn-primary.btn-lg { animation: none; }
}

/* ===== FORM ===== */
.form-card {
    background: var(--white);
    width: 100%;
}
.form-card h2 {
    color: var(--text);
    margin-bottom: 4px;
    font-size: var(--fs-lg);
    font-weight: 700;
}
.form-card .subtitle {
    color: var(--gray-600);
    margin-bottom: var(--sp-lg);
    font-size: var(--fs-sm);
}

.form-group { margin-bottom: var(--sp-md); }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text);
    font-size: var(--fs-sm);
}
.form-group label .required { color: var(--red); }

.form-control {
    width: 100%;
    padding: clamp(11px, 2.2vw, 14px) 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px; /* prevents iOS zoom */
    font-family: inherit;
    background: var(--off-white);
    color: var(--text);
    transition: border-color .2s, background .2s;
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--safaricom-green);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(0,169,79,0.1);
}
.form-control::placeholder { color: var(--gray-400); }

select.form-control {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a635d' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Form row: 1 column on mobile, 2 on tablet+ */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-md);
}
@media (min-width: 560px) {
    .form-row { grid-template-columns: 1fr 1fr; }
}

.input-prefix {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--off-white);
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.input-prefix:focus-within {
    border-color: var(--safaricom-green);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(0,169,79,0.1);
}
.input-prefix .prefix {
    background: transparent;
    color: var(--gray-600);
    padding: 0 14px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: var(--fs-sm);
    border-right: 1px solid var(--gray-200);
    white-space: nowrap;
}
.input-prefix .form-control {
    border: none;
    border-radius: 0;
    flex: 1;
    background: transparent;
    min-width: 0; /* prevents grid overflow */
}
.input-prefix .form-control:focus { box-shadow: none; }

.form-hint { font-size: var(--fs-xs); color: var(--gray-600); margin-top: 6px; }

/* ===== LOAN SUMMARY ===== */
.loan-summary {
    background: var(--safaricom-green-light);
    border-left: 3px solid var(--safaricom-green);
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius);
    margin-bottom: var(--sp-md);
}
.loan-summary .label {
    font-size: var(--fs-xs);
    color: var(--safaricom-green-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-bottom: 2px;
}
.loan-summary .value {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--text);
}
.loan-summary .meta { font-size: var(--fs-sm); color: var(--gray-600); margin-top: 2px; }

/* ===== ALERTS ===== */
.alert {
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius);
    margin-bottom: var(--sp-md);
    font-size: var(--fs-sm);
    line-height: 1.5;
}
.alert-success { background: var(--safaricom-green-light); color: var(--safaricom-green-dark); border-left: 3px solid var(--safaricom-green); }
.alert-error { background: #fdecec; color: #a01e1e; border-left: 3px solid var(--red); }
.alert-info { background: #e8f2fd; color: #1f4b85; border-left: 3px solid #2a7ad6; }
.alert-warning { background: #fef6e6; color: #8a5d10; border-left: 3px solid var(--yellow); }
.alert ul { margin-top: 4px; padding-left: 20px; }
.alert strong { font-weight: 700; }

/* ===== CONGRATS / SUCCESS ===== */
.congrats-card {
    background: var(--white);
    padding: var(--sp-md) 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.congrats-icon {
    width: clamp(80px, 18vw, 110px);
    height: clamp(80px, 18vw, 110px);
    border-radius: 50%;
    background: var(--safaricom-green-light);
    color: var(--safaricom-green);
    display: grid;
    place-items: center;
    margin: var(--sp-sm) auto var(--sp-md);
    font-size: clamp(2.2rem, 8vw, 3.4rem);
    font-weight: 800;
    animation: pop .5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.congrats-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: var(--safaricom-green-light);
    opacity: 0.4;
    z-index: -1;
    animation: ping 1.8s ease-out infinite;
}
@keyframes pop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes ping {
    0%   { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.4); opacity: 0; }
}
.congrats-card h1 {
    color: var(--safaricom-green-dark);
    font-size: var(--fs-xl);
    font-weight: 800;
    margin-bottom: var(--sp-xs);
    padding: 0 var(--sp-sm);
    line-height: 1.2;
}
.congrats-card .lead {
    color: var(--gray-600);
    font-size: var(--fs-base);
    margin-bottom: var(--sp-md);
    padding: 0 var(--sp-sm);
    line-height: 1.5;
    max-width: 520px;
}

/* ===== FEE BREAKDOWN ===== */
.fee-breakdown {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: var(--sp-md);
    margin: var(--sp-md) 0;
    text-align: left;
    width: 100%;
}
.fee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-xs) 0;
    border-bottom: 1px dashed var(--gray-200);
    font-size: var(--fs-sm);
    gap: 10px;
}
.fee-row:last-child { border-bottom: none; }
.fee-row .lbl { color: var(--gray-600); }
.fee-row .val { font-weight: 600; color: var(--text); white-space: nowrap; }
.fee-row.total { padding-top: var(--sp-sm); }
.fee-row.total .lbl { font-weight: 700; color: var(--text); font-size: var(--fs-base); }
.fee-row.total .val { color: var(--safaricom-green); font-size: var(--fs-md); font-weight: 800; }

/* ===== DETAIL LIST ===== */
.detail-list {
    text-align: left;
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 4px var(--sp-md);
    margin: var(--sp-md) 0;
    width: 100%;
}
.detail-list .item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: var(--fs-sm);
    gap: 12px;
}
.detail-list .item:last-child { border-bottom: none; }
.detail-list .k { color: var(--gray-600); flex-shrink: 0; }
.detail-list .v {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

/* ===== SPINNER ===== */
.spinner-wrap { text-align: center; padding: var(--sp-lg) 0 var(--sp-sm); }
.spinner {
    width: clamp(50px, 12vw, 72px);
    height: clamp(50px, 12vw, 72px);
    border: 5px solid var(--safaricom-green-light);
    border-top-color: var(--safaricom-green);
    border-radius: 50%;
    margin: 0 auto var(--sp-md);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== FIXED BOTTOM CTA ===== */
.bottom-cta {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--sp-sm) 0 calc(var(--sp-sm) + var(--safe-bottom));
    background: var(--white);
    border-top: 1px solid var(--gray-100);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    z-index: 50;
}

/* Subtle fade effect above the CTA — content scrolls smoothly under it */
.bottom-cta::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(to top, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.bottom-cta-inner {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding-left: clamp(16px, 4vw, 32px);
    padding-right: clamp(16px, 4vw, 32px);
}
.bottom-cta .btn { margin: 0; }
.bottom-cta-hint {
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--gray-600);
    margin-top: var(--sp-xs);
}
.bottom-cta-stack { display: grid; gap: var(--sp-xs); }

/* ===== FOOTER ===== */
.site-footer {
    background: var(--gray-800);
    color: var(--gray-200);
    padding: var(--sp-xl) 0 var(--sp-md);
    margin-top: var(--sp-xl);
    display: none; /* hidden by default on small screens to stay app-like */
}
.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
    margin-bottom: var(--sp-lg);
}
.site-footer h4 { color: var(--white); margin-bottom: var(--sp-xs); font-size: var(--fs-base); }
.site-footer p, .site-footer li { color: #b6beba; font-size: var(--fs-sm); margin-bottom: 4px; }
.site-footer a { color: #b6beba; }
.site-footer a:hover { color: var(--safaricom-green); }
.footer-bottom {
    border-top: 1px solid #3a423d;
    padding-top: var(--sp-md);
    text-align: center;
    font-size: var(--fs-xs);
    color: #8f9691;
}

/* Show footer on desktop only (since bottom CTA is still fixed) */
@media (min-width: 768px) {
    .site-footer { display: block; }
    .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}

/* ===== HELPERS ===== */
.text-center { text-align: center; }
.full-width { width: 100%; }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); }
.text-muted { color: var(--gray-600); font-size: var(--fs-sm); }

/* ===== TABLET & UP ===== */
@media (min-width: 768px) {
    .main-content { padding-top: var(--sp-lg); }
    .loan-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ===== DESKTOP ===== */
@media (min-width: 1024px) {
    .hero h1 { font-size: var(--fs-2xl); }
    .loan-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== CURRENCY CONVERTER CARD ===== */
.converter-card {
    background: var(--white);
    border: 1.5px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: var(--sp-md);
    margin-bottom: var(--sp-lg);
    box-shadow: var(--shadow);
    animation: slideInUp .5s cubic-bezier(0.25, 0.8, 0.25, 1);
}
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.converter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-md);
}
.converter-header h3 {
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.converter-rate {
    font-size: var(--fs-xs);
    color: var(--gray-600);
}
.converter-rate span {
    color: var(--safaricom-green);
    font-weight: 700;
}

.refresh-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--safaricom-green-light);
    color: var(--safaricom-green-dark);
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s, transform .3s;
    flex-shrink: 0;
}
.refresh-btn:hover { background: var(--safaricom-green); color: var(--white); }
.refresh-btn:active { transform: scale(0.9); }
.refresh-btn.spinning svg { animation: spin-refresh .6s ease-in-out; }
@keyframes spin-refresh {
    to { transform: rotate(360deg); }
}

.converter-body {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--sp-sm);
    align-items: end;
}
@media (max-width: 480px) {
    .converter-body {
        grid-template-columns: 1fr;
        gap: var(--sp-xs);
    }
}

.conv-field label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--gray-600);
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.conv-field .input-prefix { background: var(--off-white); }
.conv-field .form-control {
    font-weight: 700;
    font-size: var(--fs-md);
}

.swap-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--safaricom-green);
    color: var(--white);
    border: 3px solid var(--white);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s, transform .4s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,169,79,0.3);
    margin-bottom: 4px;
    justify-self: center;
}
.swap-btn:hover { background: var(--safaricom-green-hover); transform: scale(1.08); }
.swap-btn:active { transform: scale(0.92); }
.swap-btn.spinning {
    animation: swap-rotate .5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes swap-rotate {
    0%   { transform: rotate(0deg) scale(1); }
    50%  { transform: rotate(180deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}

@media (max-width: 480px) {
    .swap-btn {
        justify-self: center;
        margin: 4px auto;
    }
    .swap-btn.spinning { animation: swap-rotate-v .5s cubic-bezier(0.34, 1.56, 0.64, 1); }
    @keyframes swap-rotate-v {
        0%   { transform: rotate(0deg) scale(1); }
        50%  { transform: rotate(90deg) scale(1.15); }
        100% { transform: rotate(180deg) scale(1); }
    }
}

/* ===== SECTION TITLE WITH TOGGLE ===== */
.section-title.with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-sm);
    flex-wrap: wrap;
}

/* ===== CURRENCY TOGGLE PILL ===== */
.currency-toggle {
    display: inline-flex;
    background: var(--gray-100);
    border-radius: 999px;
    padding: 4px;
    position: relative;
}
.cur-opt {
    background: transparent;
    border: none;
    padding: 7px 16px;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: 999px;
    transition: color .2s;
    font-family: inherit;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}
.cur-opt.active {
    color: var(--white);
    background: var(--safaricom-green);
    box-shadow: 0 2px 8px rgba(0,169,79,0.3);
    transition: background .3s cubic-bezier(0.25, 0.8, 0.25, 1), color .3s;
}
.cur-opt:not(.active):hover { color: var(--text); }

/* ===== LOAN CARD — enhanced animations ===== */
.loan-card {
    animation: cardFadeIn .5s ease-out backwards;
}
/* Staggered entrance */
.loan-card:nth-child(1) { animation-delay: 0.05s; }
.loan-card:nth-child(2) { animation-delay: 0.10s; }
.loan-card:nth-child(3) { animation-delay: 0.15s; }
.loan-card:nth-child(4) { animation-delay: 0.20s; }
.loan-card:nth-child(5) { animation-delay: 0.25s; }
.loan-card:nth-child(6) { animation-delay: 0.30s; }
.loan-card:nth-child(7) { animation-delay: 0.35s; }
.loan-card:nth-child(8) { animation-delay: 0.40s; }

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.loan-card .amount {
    transition: transform .2s;
}
.loan-card .amount.flip {
    animation: amount-flip .4s ease-out;
}
@keyframes amount-flip {
    0%   { transform: rotateX(0);   opacity: 1; }
    50%  { transform: rotateX(90deg); opacity: 0.3; }
    100% { transform: rotateX(0);   opacity: 1; }
}

/* Currency alt-display (shown in parentheses on detail lists) */
.fee-alt {
    display: block;
    font-size: var(--fs-xs);
    color: var(--gray-600);
    font-weight: 500;
    margin-top: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .loan-card, .converter-card { animation: none; }
    .loan-card .amount.flip { animation: none; }
}

/* ===== PRINT ===== */
@media print {
    .site-header, .stepper-wrap, .bottom-cta, .site-footer { display: none !important; }
    .main-content { padding: 0 !important; }
    body { background: white; max-width: none; box-shadow: none; }
}

/* ===== CUSTOM SCROLLBAR (desktop only) ===== */
@media (min-width: 768px) and (hover: hover) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }
    ::-webkit-scrollbar-track {
        background: var(--gray-50);
    }
    ::-webkit-scrollbar-thumb {
        background: var(--gray-200);
        border-radius: 10px;
        border: 2px solid var(--gray-50);
    }
    ::-webkit-scrollbar-thumb:hover {
        background: var(--safaricom-green);
    }
    html {
        scrollbar-width: thin;
        scrollbar-color: var(--gray-200) var(--gray-50);
    }
}

/* ===== SCROLL-TRIGGERED FOCUS ===== */
/* When a focused element would be hidden behind sticky UI, scroll it into view */
.form-control:focus,
.input-prefix:focus-within {
    scroll-margin-top: 80px;
    scroll-margin-bottom: 140px; /* above the fixed bottom CTA */
}
