/* SACCO member PWA — Bootstrap 5 overrides and app layout */
:root {
  /* Colours taken from the Springing Stars logo */
  --brand: #2e3192;       /* navy: primary */
  --brand-dark: #23266f;
  --brand-soft: #e8e9f5;
  --ink: #1f2040;         /* body text */
  --muted: #62637a;
  --paper: #f5f5fa;       /* page background */
  --line: #dcdcea;
  --gold: #bc971d;        /* accent: borders, icons, highlights (not text) */
  --gold-soft: #faf4e1;
  --credit: #3f7f28;      /* logo green, darkened to read on white */
  --debit: #b3261e;

  /* logo disc: yellow, orange, magenta, purple, blue, green */
  --rainbow: linear-gradient(90deg,
    #e4c316 0 16.66%, #dc9915 16.66% 33.33%, #ce0d7a 33.33% 50%,
    #8f1a72 50% 66.66%, #2d5e9d 66.66% 83.33%, #509734 83.33% 100%);

  --nav-h: 64px;
  --top-h: 56px;

  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 1rem;
  --bs-primary: var(--brand);
  --bs-primary-rgb: 46, 49, 146;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 46, 49, 146;
  --bs-link-hover-color: var(--brand-dark);
  --bs-link-hover-color-rgb: 35, 38, 111;
  --bs-border-color: var(--line);
  --bs-border-radius: .5rem;
}

html, body { min-height: 100%; }
body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark);
  --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-dark);
}
.btn { min-height: 44px; font-weight: 600; }
.form-control, .form-select { min-height: 48px; font-size: 1rem; } /* 16px stops iOS zoom */
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(46, 49, 146, .2);
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-credit { color: var(--credit) !important; }
.text-debit { color: var(--debit) !important; }
.text-muted-2 { color: var(--muted) !important; }

/* ---------- Layout ---------- */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}
body.has-nav .app-main {
  padding-top: calc(var(--top-h) + env(safe-area-inset-top) + 1rem);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1.5rem);
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) .5rem 0;
  display: flex; align-items: center; gap: .25rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.125rem; font-weight: 700; margin: 0 0 0 .5rem; }
.topbar-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 1.35rem; text-decoration: none; border-radius: 50%;
}
.topbar-btn:active { background: var(--brand-soft); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #fff; border-top: 1px solid var(--line);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.bottom-nav-item i { font-size: 1.35rem; line-height: 1; }
.bottom-nav-item.active { color: var(--brand); }

/* ---------- Sign-in screens ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-head {
  background: var(--brand); color: #fff;
  padding: calc(2.5rem + env(safe-area-inset-top)) 1.5rem 3.5rem;
}
.auth-head .brand-mark {
  width: 56px; height: 56px; border-radius: 14px; background: #fff; display: block; margin-bottom: 1.25rem;
}
.auth-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 .25rem; letter-spacing: -.01em; }
.auth-head p { margin: 0; opacity: .85; }
.auth-sheet {
  flex: 1; background: var(--paper);
  margin-top: -1.75rem; border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.75rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
}
.auth-sheet .inner { max-width: 440px; margin: 0 auto; }
.pw-toggle { min-width: 52px; }

/* ---------- Dashboard ---------- */
.hello { font-size: 1.05rem; color: var(--muted); margin-bottom: .75rem; }
.hello strong { color: var(--ink); }

.balance-panel {
  background: var(--brand); color: #fff; border-radius: 1rem;
  padding: 1.25rem 1.25rem 1rem; margin-bottom: 1rem;
}
.balance-panel .caption { font-size: .9rem; opacity: .85; margin: 0; }
.balance-panel .figure { font-size: 2.25rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; margin: .15rem 0 .75rem; }
.balance-panel .figure small { font-size: 1rem; font-weight: 600; opacity: .8; margin-right: .25rem; letter-spacing: 0; }
.balance-panel .split { display: flex; gap: 1rem; border-top: 1px solid rgba(255,255,255,.2); padding-top: .75rem; }
.balance-panel .split div { flex: 1; }
.balance-panel .split span { display: block; font-size: .8rem; opacity: .8; }
.balance-panel .split b { font-size: 1.05rem; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1.25rem; }
.quick a {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  background: #fff; border: 1px solid var(--line); border-radius: .75rem;
  padding: .85rem .25rem; color: var(--ink); text-decoration: none; font-size: .82rem; font-weight: 600; text-align: center;
}
.quick a i { font-size: 1.4rem; color: var(--brand); }
.quick a:active { background: var(--brand-soft); }

.due-strip {
  display: flex; align-items: center; gap: .75rem;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: .75rem; padding: .85rem 1rem; margin-bottom: 1.25rem; color: var(--ink); text-decoration: none;
}
.due-strip.late { border-left-color: var(--debit); }
.due-strip i { font-size: 1.4rem; color: var(--gold); }
.due-strip.late i { color: var(--debit); }
.due-strip .grow { flex: 1; min-width: 0; }
.due-strip .small { color: var(--muted); }

/* ---------- Sections & lists ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 .5rem; }
.section-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.section-head a { font-size: .9rem; font-weight: 600; text-decoration: none; }

.list-plain { background: #fff; border: 1px solid var(--line); border-radius: .75rem; overflow: hidden; margin-bottom: 1.25rem; }
.list-plain .row-item { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.list-plain .row-item:first-child { border-top: 0; }
.list-plain .row-item .grow { flex: 1; min-width: 0; }
.list-plain .row-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-plain .row-item .sub { font-size: .82rem; color: var(--muted); }
.list-plain a.row-item:active { background: var(--brand-soft); }

.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }

/* ---------- Profile ---------- */
.profile-card { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; margin-bottom: 1.25rem; }
.profile-card dt { font-size: .8rem; color: var(--muted); font-weight: 500; }
.profile-card dd { margin-bottom: .6rem; font-weight: 600; word-break: break-word; }
.profile-card dd:last-child { margin-bottom: 0; }

/* ---------- Offline ---------- */
.offline-box { text-align: center; padding: 4rem 1.5rem; }
.offline-box i { font-size: 3rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Segmented tabs ---------- */
.seg { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: .25rem; }
.seg .nav-link { color: var(--muted); font-weight: 600; border-radius: .55rem; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.seg .nav-link.active { background: var(--brand); color: #fff; }

.list-plain .row-next { background: var(--gold-soft); box-shadow: inset 4px 0 0 var(--gold); }

/* ---------- Forms ---------- */
.form-hint { font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.input-group-text { min-height: 48px; }
.review { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; margin-bottom: 1rem; }
.review dt { font-size: .8rem; color: var(--muted); font-weight: 500; }
.review dd { font-weight: 600; margin-bottom: .7rem; word-break: break-word; }
.review dd:last-child { margin-bottom: 0; }
.review .big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }

/* ---------- Inquiries ---------- */
.pre-line { white-space: pre-line; word-break: break-word; }

.progress-steps { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.progress-steps li { font-size: .8rem; font-weight: 600; padding: .3rem .65rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.progress-steps li.now { background: var(--brand); border-color: var(--brand); color: #fff; }

.replies { display: flex; flex-direction: column; gap: .6rem; }
.reply { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: .75rem; padding: .8rem 1rem; }
.reply-body { word-break: break-word; }
.reply-meta { font-size: .78rem; color: var(--muted); margin-top: .35rem; }

/* Links inside content always use the brand colour */
.app-main a:not(.btn):not(.row-item):not(.due-strip):not(.nav-link) { color: var(--brand); }

/* Touch screens: no sticky hover colour on outline buttons */
@media (hover: none) {
  .btn-outline-primary:hover:not(:active):not(.active) { background: transparent; color: var(--brand); }
  .btn-outline-secondary:hover:not(:active) { background: transparent; color: var(--bs-secondary); }
}

/* ---------- Logo rainbow band ---------- */
.auth-head, .balance-panel { position: relative; overflow: hidden; }
.auth-head::after, .balance-panel::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--rainbow);
}
.auth-head::after { bottom: 1.75rem; }  /* sits just above the rounded sheet */
.balance-panel { padding-bottom: 1.35rem; }
.auth-head .brand-mark { width: 64px; height: 64px; border-radius: 16px; background: #fff; padding: 2px; }
.progress-steps li.now { background: var(--brand); border-color: var(--brand); }
.auth-sheet { position: relative; z-index: 1; }
