/* =========================================================
   Member portal — mobile-first "bank app" theme.
   Uses each SACCO's own --brand colour (set inline in the header).
   ========================================================= */
@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/Montserrat.woff2") format("woff2");
}

:root {
    --brand: #2563eb;
    --brand-deep: #1d4ed8;
    --ink: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: #e8ecf3;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --green: #16a34a;
    --green-bg: #e9f9ef;
    --red: #ef4444;
    --red-bg: #fdecec;
    --amber: #d97706;
    --amber-bg: #fdf3e0;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Montserrat", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}
a { text-decoration: none; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }

.portal-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); padding-bottom: 88px; }

/* Top bar */
.pnav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; position: sticky; top: 0; z-index: 30;
    background: var(--bg);
}
.pnav .greet { font-size: 13px; color: var(--muted); }
.pnav .greet b { display: block; font-size: 16px; color: var(--ink); }
.pnav .pav {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--brand); color: #fff; font-weight: 800;
    display: grid; place-items: center; font-size: 15px;
}

.pwrap { padding: 0 18px; }

/* Balance hero card */
.balance-card {
    background: linear-gradient(135deg, var(--brand-deep), var(--brand));
    color: #fff; border-radius: 22px; padding: 22px;
    box-shadow: 0 16px 34px color-mix(in srgb, var(--brand) 34%, transparent);
    position: relative; overflow: hidden;
}
.balance-card::after {
    content: ""; position: absolute; right: -40px; top: -40px;
    width: 160px; height: 160px; border-radius: 50%;
    background: rgba(255,255,255,.10);
}
.balance-card .lbl { font-size: 13px; opacity: .85; }
.balance-card .amt { font-size: 34px; font-weight: 800; margin: 4px 0 2px; }
.balance-card .sub { font-size: 12.5px; opacity: .8; }
.balance-card .acct { margin-top: 16px; display: flex; justify-content: space-between; font-size: 12.5px; opacity: .9; }

/* Mini stat chips */
.chips { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 14px 0; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
a.chip { display: block; color: inherit; text-decoration: none; transition: transform .14s, border-color .14s; }
a.chip:active, a.chip:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
a.balance-card { display: block; color: #fff; text-decoration: none; }
.chip .cl { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.chip .cv { font-size: 15px; font-weight: 800; margin-top: 3px; }
.chip .cv.red { color: var(--red); }
.chip .cv.green { color: var(--green); }

/* Quick actions */
.pactions { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 6px 0 18px; }
.pact { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; text-align: center; box-shadow: var(--shadow); }
.pact .ic { width: 34px; height: 34px; margin: 0 auto 6px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); display: grid; place-items: center; }
.pact .ic svg { width: 18px; height: 18px; }
.pact span { font-size: 11px; font-weight: 700; color: var(--muted); }

/* Section header */
.psec { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.psec h2 { font-size: 15px; }
.psec a { font-size: 12.5px; color: var(--brand); font-weight: 700; }

/* Cards / lists */
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pcard.pad { padding: 16px; }

.trow { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: none; }
.trow .tic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.tic.in { background: var(--green-bg); color: var(--green); }
.tic.out { background: var(--red-bg); color: var(--red); }
.tic.loan { background: var(--amber-bg); color: var(--amber); }
.tic svg { width: 18px; height: 18px; }
.trow .tbody { flex: 1; min-width: 0; }
.trow .tbody b { display: block; font-size: 14px; }
.trow .tbody span { font-size: 12px; color: var(--faint); }
.trow .tamt { font-weight: 800; font-size: 14px; }
.tamt.in { color: var(--green); }
.tamt.out { color: var(--red); }

/* Loan card */
.loan-card { padding: 16px; border-bottom: 1px solid var(--line); }
.loan-card:last-child { border-bottom: none; }
.loan-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.loan-top .lt-title { font-size: 14px; font-weight: 800; }
.loan-top .lt-sub { font-size: 12px; color: var(--faint); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.loan-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.loan-meta b { color: var(--ink); }

.pbadge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.pbadge.active { background: var(--green-bg); color: var(--green); }
.pbadge.pending { background: var(--amber-bg); color: var(--amber); }
.pbadge.completed { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
.pbadge.rejected, .pbadge.arrears { background: var(--red-bg); color: var(--red); }

.pempty { text-align: center; padding: 30px 18px; color: var(--faint); font-size: 13.5px; }

/* Detail list (profile) */
.pdl { }
.pdl > div { display: flex; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.pdl > div:last-child { border-bottom: none; }
.pdl dt { color: var(--muted); margin: 0; }
.pdl dd { margin: 0; font-weight: 600; text-align: right; }

/* Forms */
.pfield { margin-bottom: 14px; }
.pfield label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.pfield input {
    width: 100%; padding: 13px 14px; border: 1.5px solid var(--line);
    border-radius: 12px; font-family: inherit; font-size: 14.5px; background: #fff;
}
.pfield input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.pbtn { width: 100%; padding: 14px; border: 0; border-radius: 12px; font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; }
.pbtn-green { background: var(--brand); color: #fff; }
.pbtn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }

.p-alert { padding: 12px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 14px; }
.p-alert-ok { background: var(--green-bg); color: #14532d; }
.p-alert-err { background: var(--red-bg); color: #7f1d1d; }

/* Bottom tab bar */
.ptabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    max-width: 520px; margin: 0 auto;
    background: var(--surface); border-top: 1px solid var(--line);
    display: flex; justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(15,23,42,.06);
}
.ptab { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--faint); font-size: 10.5px; font-weight: 700; padding: 4px 12px; }
.ptab svg { width: 22px; height: 22px; }
.ptab.active { color: var(--brand); }

/* Portal auth (login) */
.portal-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
    background: radial-gradient(700px 400px at 50% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%), var(--bg); }
.pauth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 32px 26px; box-shadow: 0 20px 50px rgba(15,23,42,.10); }
.pauth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; margin-bottom: 22px; }
.pauth-brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; }
.pauth-card h1 { font-size: 23px; margin-bottom: 5px; }
.pauth-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.pauth-alt { font-size: 12.5px; color: var(--muted); margin: 18px 0 6px; text-align: center; }
.pauth-back { display: block; text-align: center; font-size: 13px; font-weight: 700; color: var(--brand); }

@media print { .ptabs, .pnav, .pactions { display: none !important; } }
