/* =========================================================
   COOP Central — Member App (branded per cooperative via CSS vars)
   --p primary, --p-dark, --p-soft, --s secondary, --s-soft, --on-p
   ========================================================= */
:root { --navy: #0A2A66; --ink: #1F3157; --muted: #5B6880; --line: #E3E9F3; --bg: #F3F6FB; --card: #FFFFFF; --green: #1E8E3E; --red: #C5221F; --amber: #B45309;
  --font-head: 'Poppins', 'Segoe UI', Arial, sans-serif; --font-body: 'DM Sans', 'Segoe UI', Arial, sans-serif; --nav-h: 68px; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--ink); background: #E9EEF6; }
img { max-width: 100%; display: block; }
a { color: var(--p); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-head); color: var(--navy); margin: 0 0 .4em; line-height: 1.25; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .7em; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.text-center { text-align: center; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--p) 55%, white); outline-offset: 2px; }

.app-shell { position: relative; max-width: 520px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--bg); box-shadow: 0 0 60px rgba(10, 42, 102, .08); display: flex; flex-direction: column; }
.app-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: var(--navy); }
.app-brand img { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.app-brand span { font-family: var(--font-head); font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title { flex: 1; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--navy); cursor: pointer; }
.top-btn:active { background: #EEF2F8; }
.top-btn .dot { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #E11D48; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; }
.top-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--p), var(--s)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .82rem; margin-left: 2px; }
.app-main { flex: 1; padding: 16px 14px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.app-main.guest { padding-bottom: 32px; }

/* bottom nav */
.app-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(10,42,102,.06); }
.app-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: #7A879C; font-size: .7rem; font-weight: 600; }
.app-nav a.active { color: var(--p); }
.app-nav a .ic { width: 23px; height: 23px; }
.nav-qr .qr-bubble { width: 50px; height: 50px; margin-top: -24px; border-radius: 50%; background: var(--p); color: var(--on-p); display: grid; place-items: center; box-shadow: 0 8px 20px color-mix(in srgb, var(--p) 40%, transparent); border: 4px solid #fff; }

/* cards */
.card { background: var(--card); border-radius: 18px; padding: 16px; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(10,42,102,.04); }
.card + .card, .section + .section { margin-top: 14px; }
.section { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head a { font-size: .85rem; font-weight: 600; }

.greet { margin: 2px 0 12px; }
.greet small { color: var(--muted); }
.greet h1 { font-size: 1.35rem; margin: 0; }
.balance-card { position: relative; overflow: hidden; border-radius: 22px; padding: 18px; color: #fff; background: linear-gradient(135deg, var(--p-dark), var(--p) 60%, var(--s)); box-shadow: 0 14px 30px color-mix(in srgb, var(--p) 35%, transparent); }
.balance-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.1); }
.balance-card .bc-label { font-size: .82rem; opacity: .9; display: flex; align-items: center; gap: 8px; }
.balance-card .bc-amt { font-family: var(--font-head); font-size: 2rem; font-weight: 700; margin: 4px 0 2px; letter-spacing: -.01em; }
.balance-card .bc-acct { font-size: .85rem; opacity: .9; }
.bc-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; position: relative; z-index: 1; }
.eye-btn { border: 0; background: rgba(255,255,255,.18); color: #fff; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.eye-btn .ic { width: 16px; height: 16px; }
.bc-btn { background: #fff; color: var(--p-dark); border-radius: 12px; padding: 8px 12px; font-weight: 700; font-size: .82rem; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.bc-btn .ic { width: 16px; height: 16px; }
.masked .bc-amt-val { filter: blur(8px); }

.qa-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; background: #fff; border: 1px solid var(--line); border-radius: 16px; color: var(--navy); font-size: .74rem; font-weight: 600; text-align: center; line-height: 1.2; }
.qa:active { transform: scale(.97); }
.qa .qa-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--p-soft); color: var(--p); }
.qa .qa-ic.s { background: var(--s-soft); color: var(--s); }
.qa.off { opacity: .45; }

.promo { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; background: linear-gradient(135deg, var(--p-soft), #fff); border: 1px solid var(--line); color: var(--navy); }
.promo .ic { width: 34px; height: 34px; color: var(--p); }
.promo strong { display: block; }
.promo small { color: var(--muted); }

/* lists */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li a, .tx-list li > div { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid #EEF2F8; color: inherit; }
.tx-list li:last-child a, .tx-list li:last-child > div { border-bottom: 0; }
.tx-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: #F1F4F9; color: var(--navy); }
.tx-ic.credit { background: #E7F6EC; color: var(--green); }
.tx-ic.debit { background: #FDEEEE; color: var(--red); }
.tx-ic .ic { width: 19px; height: 19px; }
.tx-main { flex: 1; min-width: 0; }
.tx-main strong { display: block; font-size: .92rem; color: var(--navy); }
.tx-main small { color: var(--muted); font-size: .78rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .92rem; }
.tx-amt.credit { color: var(--green); } .tx-amt.debit { color: var(--ink); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .86rem; color: var(--navy); }
.req { color: #D93025; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 12px 14px; border: 1px solid #D5DEEC; border-radius: 14px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px color-mix(in srgb, var(--p) 18%, transparent); }
.mpin-input { letter-spacing: .6em; text-align: center; font-size: 1.3rem !important; font-weight: 700; }
.amount-input { font-family: var(--font-head); font-size: 1.6rem !important; font-weight: 700; text-align: center; }
.help { color: var(--muted); font-size: .8rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; font: inherit; font-weight: 700; font-size: .95rem; padding: 13px 18px; border-radius: 14px; border: 1.5px solid var(--p); background: var(--p); color: var(--on-p); cursor: pointer; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-outline { background: #fff; color: var(--p); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn-sm { padding: 8px 12px; font-size: .84rem; border-radius: 11px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { position: relative; }
.chip-opt input { position: absolute; opacity: 0; pointer-events: none; }
.chip-opt span { display: inline-block; padding: 9px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; font-size: .9rem; cursor: pointer; }
.chip-opt input:checked + span { border-color: var(--p); background: var(--p-soft); color: var(--p-dark); }
.chip-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--p) 55%, white); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--p); flex: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }

/* alerts & badges */
.flash-stack { display: grid; gap: 8px; margin-bottom: 12px; }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 14px; font-weight: 500; font-size: .9rem; border: 1px solid; }
.alert .ic { width: 19px; height: 19px; }
.alert span { flex: 1; }
.alert-x { border: 0; background: none; color: inherit; opacity: .6; padding: 0; cursor: pointer; }
.alert-x .ic { width: 15px; height: 15px; }
.alert-success { background: #E9F7EE; border-color: #BFE3C9; color: #17602F; }
.alert-error { background: #FDECEA; border-color: #F5C2BE; color: #9B1C1C; }
.alert-info { background: #EAF1FD; border-color: #C7D7F2; color: #0A3C8F; }
.alert-warning { background: #FEF3E2; border-color: #F6D6A8; color: #7A3A05; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-green { background: #E7F6EC; color: #17602F; } .badge-amber { background: #FEF3E2; color: #8A4106; } .badge-red { background: #FDECEA; color: #9B1C1C; }
.badge-blue { background: #EAF1FD; color: #0A47AA; } .badge-gray { background: #EEF1F6; color: #4B5568; } .badge-purple { background: #F1EAFE; color: #5B21B6; }

/* guest / welcome */
.welcome { display: flex; flex-direction: column; min-height: calc(100dvh - 48px); text-align: center; }
.welcome .w-logo { width: 120px; height: 120px; object-fit: contain; margin: 18px auto 10px; }
.welcome h1 { font-size: 1.6rem; margin-bottom: 4px; }
.welcome .w-tag { color: var(--muted); margin-bottom: 18px; }
.welcome .w-art { flex: 1; min-height: 160px; border-radius: 24px; margin: 6px 0 20px; background: radial-gradient(120% 80% at 50% 100%, color-mix(in srgb, var(--s) 45%, white), transparent 70%), linear-gradient(180deg, var(--p-soft), #fff); display: grid; place-items: center; }
.welcome .w-art .ic { width: 84px; height: 84px; color: var(--p); opacity: .85; }
.welcome .w-actions { display: grid; gap: 10px; }
.powered { margin-top: 20px; color: var(--muted); font-size: .78rem; display: flex; align-items: center; justify-content: center; gap: 6px; }
.powered img { height: 18px; width: auto; }
.auth-box { max-width: 420px; margin: 0 auto; }
.auth-box .a-logo { width: 72px; height: 72px; object-fit: contain; margin: 4px auto 10px; }
.auth-box h1 { text-align: center; font-size: 1.4rem; }
.auth-box .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

/* QR & receipt */
.qr-card { text-align: center; padding: 22px 16px; }
.qr-box { width: 240px; max-width: 100%; margin: 12px auto; padding: 12px; background: #fff; border-radius: 18px; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: auto; display: block; }
.receipt { text-align: center; }
.receipt .r-ic { width: 64px; height: 64px; border-radius: 50%; margin: 8px auto 10px; display: grid; place-items: center; background: #E7F6EC; color: var(--green); }
.receipt .r-ic.debit { background: var(--p-soft); color: var(--p); }
.receipt .r-ic .ic { width: 32px; height: 32px; }
.receipt .r-amt { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; margin: 0 0 14px; }
.receipt .r-amt.credit { color: var(--green); }
.receipt dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; text-align: left; margin: 0; padding: 14px; background: #F7F9FC; border-radius: 14px; font-size: .88rem; }
.receipt dt { color: var(--muted); } .receipt dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.confirm-box { background: #F7F9FC; border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.confirm-box .row-b { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: .92rem; }
.confirm-box .row-b span { color: var(--muted); }
.confirm-box .row-b strong { text-align: right; }
.svc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; margin: 0 auto 8px; color: #A9B6CC; }
.empty h3 { margin-bottom: 4px; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a, .menu-list button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid #EEF2F8; background: none; font: inherit; color: var(--ink); font-weight: 600; text-align: left; cursor: pointer; }
.menu-list li:last-child a, .menu-list li:last-child button { border-bottom: 0; }
.menu-list .ic { color: var(--p); }
.menu-list .chev { margin-left: auto; color: #A9B6CC; width: 18px; height: 18px; }
.loan-card { padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.loan-card + .loan-card { margin-top: 10px; }
.progress { height: 8px; background: #EEF2F8; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress span { display: block; height: 100%; background: var(--s); border-radius: 999px; }
.member-card { position: relative; border-radius: 18px; padding: 18px; color: #fff; aspect-ratio: 1.586; background: linear-gradient(135deg, #0A2A66, var(--p) 55%, var(--s)); overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; max-width: 360px; margin: 0 auto; }
.member-card .chip-gold { width: 42px; height: 32px; border-radius: 6px; background: linear-gradient(135deg, #F6D57A, #C9A23B); }
.member-card .mc-num { font-family: ui-monospace, monospace; font-size: 1.15rem; letter-spacing: .12em; }
.member-card .mc-row { display: flex; justify-content: space-between; align-items: flex-end; font-size: .78rem; text-transform: uppercase; }
.scan-modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; color: #fff; text-align: center; }
.scan-modal video { width: 100%; max-width: 360px; border-radius: 18px; aspect-ratio: 1; object-fit: cover; background: #000; }
.scan-modal .btn { margin-top: 16px; }

/* install */
.install-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 45; width: calc(100% - 24px); max-width: 496px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 10px 10px 10px 12px; box-shadow: 0 16px 40px rgba(10,42,102,.22); }
.guest + .install-banner, .member-app:not(:has(.app-nav)) .install-banner { bottom: calc(12px + env(safe-area-inset-bottom)); }
.ib-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--p-soft); color: var(--p); flex: none; }
.install-banner div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.install-banner strong { color: var(--navy); font-size: .92rem; }
.install-banner div span { color: var(--muted); font-size: .78rem; }
.ib-x { border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
.ib-x .ic { width: 16px; height: 16px; }
.install-ios { position: fixed; inset: auto 0 0 0; z-index: 95; padding: 12px; }
.ios-card { position: relative; max-width: 460px; margin: 0 auto; background: #fff; border-radius: 20px; padding: 18px; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
.ios-card .ib-x { position: absolute; top: 8px; right: 8px; }
.ios-card ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.standalone .install-banner, .standalone [data-install] { display: none !important; }

@media (max-width: 360px) {
  .qa-grid { gap: 6px; } .qa { font-size: .68rem; padding: 10px 2px; } .qa .qa-ic { width: 38px; height: 38px; }
  .balance-card .bc-amt { font-size: 1.6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 560px) { body { padding: 0; } }
