/* =====================================================================
   CreditNest — Design System
   Shared styles for Admin (desktop SaaS) + Borrower (mobile app)
   Layered on top of Bootstrap 5.3 — refines, never fights it.
   ===================================================================== */

:root {
  /* Brand */
  --brand:        #1b6ca8;
  --brand-2:      #2aa9b0;
  --brand-ink:    #0f4c73;
  --brand-grad:   linear-gradient(135deg, #1b6ca8 0%, #2493ac 55%, #2aa9b0 100%);

  /* Surfaces */
  --bg:           #f4f7fa;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e6eaf0;
  --border-strong:#d5dbe4;

  /* Text */
  --text:         #1f2933;
  --muted:        #6b7280;
  --faint:        #9aa4b2;

  /* Semantic */
  --success:      #15803d;  --success-bg: #dcfce7;
  --warning:      #b45309;  --warning-bg: #fef3c7;
  --danger:       #b91c1c;  --danger-bg:  #fee2e2;
  --info:         #1b6ca8;  --info-bg:    #e0f2fe;
  --money:        #0f766e;

  /* Shape */
  --r-xs: 8px;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 26px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow:    0 6px 20px rgba(16,24,40,.08);
  --shadow-lg: 0 18px 40px rgba(16,24,40,.16);

  /* Layout */
  --sidebar-w: 264px;
  --appbar-h:  60px;
  --bottomnav-h: 66px;

  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================ BASE ============================ */
* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: .1px;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); }

.text-money { color: var(--money) !important; font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.muted, .text-subtle { color: var(--muted) !important; }

/* Focus visibility (touch + keyboard) */
:focus-visible {
  outline: 3px solid rgba(27,108,168,.35);
  outline-offset: 2px;
}

/* ====================== BOOTSTRAP REFINEMENTS ====================== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card .card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.btn {
  border-radius: 999px;
  font-weight: 600;
  padding: .55rem 1.15rem;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .8rem; font-size: .82rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1.02rem; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
  box-shadow: 0 8px 20px rgba(27,108,168,.28);
}
.btn-success { background: var(--money); border-color: var(--money); }
.btn-success:hover { background: #0b5d56; border-color: #0b5d56; }

.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

.badge { font-weight: 600; padding: .4em .7em; border-radius: 999px; letter-spacing: .2px; }

.form-control, .form-select {
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  padding: .62rem .85rem;
  font-size: .95rem;
  min-height: 46px;
  background: var(--surface);
  color: var(--text);
}
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27,108,168,.15);
}
.form-label { font-weight: 600; font-size: .87rem; color: #384250; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.alert { border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.alert-success { background: var(--success-bg); border-color: #bbf7d0; color: #14532d; }
.alert-danger  { background: var(--danger-bg);  border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); border-color: #fde68a; color: #78350f; }
.alert-info    { background: var(--info-bg);    border-color: #bae6fd; color: #075985; }

.table { color: var(--text); }
.table > :not(caption) > * > * { padding: .78rem .9rem; }
.table thead th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .55px;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table tbody tr { border-color: var(--border); }
.table-hover tbody tr:hover { background: #f1f6fb; }

/* ===================== STATUS BADGE (shared) ===================== */
.s-badge {
  display: inline-flex; align-items: center; gap: .38rem;
  padding: .34em .7em; border-radius: 999px;
  font-size: .76rem; font-weight: 700; letter-spacing: .2px;
  border: 1px solid transparent; white-space: nowrap;
}
.s-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-pending      { background: #eef1f5; color: #4b5563; }
.s-under_review { background: var(--warning-bg); color: var(--warning); }
.s-approved     { background: var(--info-bg); color: var(--info); }
.s-disbursed    { background: #e6f5ee; color: var(--money); }
.s-active       { background: #e6f5ee; color: var(--money); }
.s-rejected     { background: var(--danger-bg); color: var(--danger); }
.s-overdue      { background: var(--danger-bg); color: var(--danger); }
.s-cleared      { background: var(--success-bg); color: var(--success); }
.s-completed    { background: var(--success-bg); color: var(--success); }

/* ============================ PAGE HEAD ============================ */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1, .page-head h2 { margin: 0; font-size: 1.5rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

/* ============================ STAT CARDS ============================ */
.stat-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat .stat-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; margin-bottom: .4rem;
  display: flex; align-items: center; gap: .4rem;
}
.stat .stat-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .stat-hint { font-size: .8rem; color: var(--faint); margin-top: .25rem; }
.stat.accent-brand   { border-top: 3px solid var(--brand); }
.stat.accent-money   { border-top: 3px solid var(--money); }
.stat.accent-warning { border-top: 3px solid var(--warning); }
.stat.accent-danger  { border-top: 3px solid var(--danger); }

/* ============================ KEY / VALUE ============================ */
.kv { display: grid; grid-template-columns: 1fr auto; gap: .55rem 1rem; }
.kv dt { color: var(--muted); font-weight: 600; font-size: .88rem; }
.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ============================ PROGRESS ============================ */
.pct-bar { height: 10px; border-radius: 999px; background: #e8edf3; overflow: hidden; }
.pct-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width .4s ease; }

/* ============================ TIMELINE ============================ */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 1.35rem 1.9rem; color: var(--muted);
}
.timeline li::before {
  content: ""; position: absolute; left: 4px; top: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline li::after {
  content: ""; position: absolute; left: 10px; top: 16px; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline li:last-child::after { display: none; }
.timeline li.done { color: var(--text); }
.timeline li.done::before { background: var(--money); border-color: var(--money); }
.timeline li.current { color: var(--text); font-weight: 700; }
.timeline li.current::before { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px rgba(27,108,168,.15); }
.timeline li.rejected::before { background: var(--danger); border-color: var(--danger); }
.timeline .t-title { font-weight: 700; display: block; }
.timeline .t-meta { font-size: .8rem; color: var(--faint); }

/* ============================ EMPTY STATE ============================ */
.empty {
  text-align: center; padding: 3rem 1.25rem; color: var(--muted);
}
.empty .icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 1rem;
  display: grid; place-items: center; font-size: 1.6rem;
  background: var(--surface-2); color: var(--faint); border: 1px solid var(--border);
}
.empty h3 { font-size: 1.05rem; margin-bottom: .35rem; color: var(--text); }

/* =====================================================================
   ADMIN SHELL — desktop-first SaaS dashboard
   ===================================================================== */
.admin-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #0e2b40;
  color: #cdd9e5;
  z-index: 1050;
  display: flex; flex-direction: column;
  transition: transform .28s ease;
}
.admin-sidebar .brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.15rem 1.25rem; color: #fff; font-weight: 800; font-size: 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-sidebar .brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }
.admin-sidebar .nav { padding: .85rem .7rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; flex-wrap: nowrap; }  /* scroll, never wrap into a 2nd column */
.admin-sidebar .nav-section {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .8px;
  color: #6f8296; font-weight: 700; padding: .9rem .9rem .35rem;
}
.admin-sidebar .nav-link {
  display: flex; align-items: center; gap: .8rem;
  color: #cdd9e5; padding: .7rem .9rem; border-radius: var(--r-sm);
  font-weight: 600; font-size: .92rem; margin-bottom: 2px;
  white-space: nowrap;
}
.admin-sidebar .nav-link i { width: 20px; text-align: center; font-size: .95rem; opacity: .85; flex-shrink: 0; }
.admin-sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-sidebar .nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(27,108,168,.4); }
.admin-sidebar .nav-link.active i { opacity: 1; }

/* Logout pinned to the sidebar bottom — stays visible no matter how long the
   menu is or how far the page is zoomed (the .nav above it scrolls instead). */
.admin-sidebar-footer {
  flex-shrink: 0;
  padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
  background: #0e2b40;
}
.admin-sidebar-footer .nav-link { margin-bottom: 0; }
.admin-sidebar-footer .logout-link { color: #f7c9c9; }
.admin-sidebar-footer .logout-link:hover { background: rgba(220,53,69,.22); color: #fff; }

/* Quick logout beside the signed-in admin in the topbar */
.admin-topbar .topbar-logout {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); background: var(--surface);
}
.admin-topbar .topbar-logout:hover { background: #dc3545; color: #fff; border-color: #dc3545; }

/* Live notification bell + mute toggle (static/js/notify-bell.js) */
.admin-topbar .topbar-icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); background: var(--surface);
}
.admin-topbar .topbar-icon:hover { color: var(--brand, #1b6ca8); border-color: currentColor; }
.admin-topbar .topbar-icon.is-muted { color: #dc3545; }
.admin-topbar .bell-badge {
  position: absolute; top: -5px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #dc3545; color: #fff; font-size: .68rem; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.admin-topbar .topbar-icon.bell-ring i { animation: bell-ring .9s ease-in-out 2; transform-origin: 50% 0; }
@keyframes bell-ring {
  0%, 100% { transform: rotate(0); } 20% { transform: rotate(16deg); } 40% { transform: rotate(-14deg); }
  60% { transform: rotate(9deg); } 80% { transform: rotate(-5deg); }
}
.admin-topbar .bell-sound-hint {
  font-size: .75rem; color: #8a5a00; background: #fff4d6; border: 1px solid #f1d48a;
  border-radius: 999px; padding: .2rem .6rem; cursor: pointer; white-space: nowrap;
}
@media (max-width: 575.98px) { .admin-topbar .bell-sound-hint { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .admin-topbar .topbar-icon.bell-ring i { animation: none; } }

/* Notifications list: on phones the action buttons go under the text */
.notif-row .notif-text { min-width: 0; }
@media (max-width: 575.98px) {
  .notif-row { flex-wrap: wrap; }
  .notif-row .notif-text { flex-basis: calc(100% - 3rem); }
  .notif-row .notif-actions { width: 100%; padding-left: 3rem; }
}

.admin-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: var(--appbar-h); padding: 0 1.4rem;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.admin-topbar .title { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.admin-topbar > .d-flex { min-width: 0; }
.admin-topbar .user-chip {
  display: flex; align-items: center; gap: .6rem;
  font-size: .85rem; color: var(--muted);
  flex-shrink: 0;
}
.admin-topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.admin-content { padding: 1.6rem 1.6rem 2.5rem; flex: 1; width: 100%; max-width: 1400px; }
/* Full-bleed pages (loan list, reports) use the whole viewport width */
.admin-content.is-wide { max-width: none; }

.admin-hamburger { display: none; }
.admin-overlay { display: none; }

@media (max-width: 991.98px) {
  .admin-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .admin-sidebar.show { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-hamburger { display: inline-flex; }
  .admin-overlay.show {
    display: block; position: fixed; inset: 0;
    background: rgba(8,20,32,.5); z-index: 1040;
  }
  .admin-content { padding: 1.1rem; }
}

/* Admin data-table wrapper: horizontal scroll on small screens */
.data-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
.data-wrap .table { margin: 0; }

/* Sticky header — stays put while the list scrolls */
.data-wrap .table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--border-strong);
}

/* Vertical-scroll variant for long lists (loan list, reports, defaulters) */
.data-wrap.scroll-y {
  overflow-y: auto;
  max-height: calc(100vh - 250px);
}
/* Totals row stays pinned to the bottom while the list scrolls */
.data-wrap.scroll-y .table tfoot td,
.data-wrap.scroll-y .table tfoot th {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--surface);
  box-shadow: inset 0 1px 0 var(--border-strong);
}

/* Cells wrap to fit the screen; numeric columns stay on one line */
.data-wrap .table tbody td { white-space: normal; word-break: break-word; vertical-align: middle; }
.data-wrap .table tbody td.tnum { white-space: nowrap; word-break: normal; }
.data-wrap .table th { white-space: nowrap; }

/* =====================================================================
   BORROWER SHELL — mobile-first fintech app
   ===================================================================== */
.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(16,24,40,.06);
  display: flex; flex-direction: column;
  position: relative;
}

.app-bar {
  position: sticky; top: 0; z-index: 30;
  height: var(--appbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top);
  background: var(--brand-grad);
  color: #fff;
}
.app-bar .app-bar-title { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.app-bar .app-bar-title img { width: 26px; height: 26px; object-fit: contain; border-radius: 6px; background: rgba(255,255,255,.15); padding: 2px; }
.app-bar a, .app-bar button { color: #fff; }
.app-bar .icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.16); color: #fff;
  display: grid; place-items: center; font-size: 1rem;
}
.app-bar .icon-btn:active { background: rgba(255,255,255,.28); }

.app-content {
  flex: 1;
  padding: 1.1rem 1rem calc(var(--bottomnav-h) + 1.4rem + env(safe-area-inset-bottom));
}

/* Greeting header on dashboard */
.greeting { margin-bottom: 1.15rem; }
.greeting .hi { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.greeting .sub { color: var(--muted); font-size: .92rem; margin-top: .15rem; }

/* Hero balance card */
.hero-card {
  background: var(--brand-grad);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 1.3rem 1.35rem;
  box-shadow: 0 16px 34px rgba(27,108,168,.32);
  margin-bottom: 1.15rem;
}
.hero-card .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; opacity: .85; font-weight: 700; }
.hero-card .amount { font-size: 2rem; font-weight: 800; margin: .25rem 0 .1rem; font-variant-numeric: tabular-nums; }
.hero-card .row-split { display: flex; gap: 1rem; margin-top: 1.05rem; }
.hero-card .row-split > div { flex: 1; }
.hero-card .row-split .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; opacity: .8; font-weight: 700; }
.hero-card .row-split .v { font-size: 1.02rem; font-weight: 700; margin-top: .1rem; font-variant-numeric: tabular-nums; }

/* Mobile stat pair */
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.15rem; }
.mini {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: .95rem 1rem; box-shadow: var(--shadow-sm);
}
.mini .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.mini .v { font-size: 1.25rem; font-weight: 800; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.mini .sub { font-size: .78rem; color: var(--faint); margin-top: .15rem; }

/* Section title */
.sec-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 1.4rem 0 .8rem; font-size: 1.05rem; font-weight: 800;
}
.sec-title a { font-size: .82rem; font-weight: 700; }

/* Loan card (mobile list) */
.loan-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1rem 1.05rem; box-shadow: var(--shadow-sm);
  margin-bottom: .85rem; display: block; color: inherit;
}
.loan-card:active { transform: scale(.995); }
.loan-card .lc-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .55rem; }
.loan-card .lc-purpose { font-weight: 700; }
.loan-card .lc-id { font-size: .78rem; color: var(--faint); font-weight: 600; }
.loan-card .lc-amount { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.loan-card .lc-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .82rem; color: var(--muted); margin-top: .5rem; }
.loan-card .lc-meta b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.loan-card .lc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .75rem; padding-top: .7rem; border-top: 1px solid var(--border); }

/* Verified-profile banner */
.verify-banner {
  display: flex; align-items: center; gap: .9rem;
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--r);
  padding: .9rem 1rem;
}
.verify-banner .vb-icon {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.1rem;
  background: var(--success); color: #fff;
}

/* Payment-method chooser (repay screen) */
.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.pay-method {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  text-align: left; padding: .8rem .9rem;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.pay-method i { font-size: 1.05rem; color: var(--muted); margin-bottom: .2rem; }
.pay-method .pm-title { font-weight: 700; }
.pay-method .pm-sub { font-size: .76rem; color: var(--muted); }
.pay-method.active {
  border-color: var(--money);
  background: color-mix(in srgb, var(--money) 7%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--money) 18%, transparent);
}
.pay-method.active i { color: var(--money); }
@media (max-width: 400px) { .pay-methods { grid-template-columns: 1fr; } }

/* M-Pesa manual paybill card */
.paybill-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--money);
  border-radius: var(--r); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm);
}
.paybill-card .pb-head { font-weight: 800; margin-bottom: .6rem; }
.paybill-card .pb-steps { margin: 0 0 .7rem; padding-left: 1.15rem; }
.paybill-card .pb-steps li { padding: .18rem 0; font-size: .93rem; }
.paybill-card .pb-val {
  font-variant-numeric: tabular-nums; letter-spacing: .3px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .05rem .4rem; border-radius: 6px;
}

/* Rejection reason note (borrower-facing) */
.reject-note {
  background: var(--danger-bg);
  color: #7f1d1d;
  border: 1px solid #fecaca;
  border-radius: var(--r-sm);
  padding: .6rem .75rem;
  font-size: .85rem;
  line-height: 1.4;
}

/* Profile completion prompt */
.profile-prompt {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--r); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
  margin-bottom: 1.15rem;
}
.profile-prompt .pp-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.profile-prompt .pp-pct { color: var(--warning); font-weight: 800; }
.profile-prompt .pct-bar { margin: .7rem 0 .9rem; }

/* Bottom navigation */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 520px;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch; z-index: 40;
  box-shadow: 0 -6px 24px rgba(16,24,40,.07);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .18rem; color: var(--faint); font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.bottom-nav a i { font-size: 1.15rem; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.fab {
  flex: 0 0 auto; width: 66px; position: relative;
}
.bottom-nav a.fab .fab-btn {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  display: grid; place-items: center; font-size: 1.3rem;
  box-shadow: 0 10px 22px rgba(27,108,168,.4);
  border: 4px solid var(--bg);
}
.bottom-nav a.fab span { margin-top: 34px; color: var(--brand); }

/* Mobile-friendly form card */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1.15rem;
}
.form-card .form-control, .form-card .form-select { min-height: 50px; }

/* Stepper (loan application) */
.stepper { display: flex; align-items: center; margin-bottom: 1.25rem; }
.stepper .step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; position: relative; }
.stepper .step .dot {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: .82rem;
  background: #e8edf3; color: var(--muted); border: 2px solid transparent; z-index: 2;
}
.stepper .step .lbl { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; text-align: center; }
.stepper .step:not(:last-child)::after {
  content: ""; position: absolute; top: 15px; left: 50%; width: 100%; height: 2px; background: var(--border-strong); z-index: 1;
}
.stepper .step.active .dot { background: var(--brand); color: #fff; border-color: rgba(27,108,168,.25); box-shadow: 0 0 0 4px rgba(27,108,168,.14); }
.stepper .step.done .dot { background: var(--money); color: #fff; }
.stepper .step.done::after { background: var(--money); }
.stepper .step.active .lbl, .stepper .step.done .lbl { color: var(--text); }

/* Steps are visible by default so the form still works without JS.
   The wizard adds .js-steps to the form once it has initialised. */
.fstep { display: block; }
form.js-steps .fstep { display: none; }
form.js-steps .fstep.active { display: block; animation: fadeUp .25s ease; }

/* Select2 — match the form controls */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
  height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  display: flex; align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.4; padding-left: .85rem; color: var(--text);
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 44px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27,108,168,.15);
}
.select2-dropdown {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  z-index: 1080;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--brand);
}
.select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border-strong); border-radius: var(--r-xs); padding: .45rem .6rem;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.review-list { list-style: none; padding: 0; margin: 0; }
.review-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.review-list li b { font-weight: 700; text-align: right; }

/* "Choose a loan option" comparison panel (apply-loan) */
.cat-list { display: grid; gap: .55rem; margin-bottom: .5rem; }
.cat-row {
  width: 100%; text-align: left;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: .7rem .85rem; cursor: pointer;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.cat-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cat-row.selected {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
  box-shadow: 0 0 0 3px rgba(27,108,168,.12);
}
.cat-row .cat-main {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
}
.cat-row .cat-name { font-weight: 700; }
.cat-row .cat-rate { font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.cat-row .cat-rate small { font-weight: 600; color: var(--muted); }
.cat-row .cat-meta {
  font-size: .8rem; color: var(--muted); margin-top: .25rem;
  display: flex; flex-wrap: wrap; gap: .1rem .4rem;
}
.cat-row .cat-cost { color: var(--money); font-weight: 700; margin-left: auto; }

/* Loan cost breakdown on the review step */
.cost-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.1rem;
}
.cost-card .cost-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 700; color: var(--muted); margin-bottom: .6rem;
}
.cost-card .cost-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .4rem 0; font-size: .93rem;
}
.cost-card .cost-row + .cost-row { border-top: 1px dashed var(--border); }
.cost-card .cost-row b { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.cost-card .cost-row.total {
  margin-top: .2rem; padding-top: .6rem;
  border-top: 2px solid var(--border-strong);
  font-size: 1.05rem;
}
.cost-card .cost-row.total b { color: var(--money); font-weight: 800; }
.cost-card .cost-note { margin: .6rem 0 0; font-size: .78rem; color: var(--faint); }
.cost-card .cost-note[hidden] { display: none; }
#c-warn:not([hidden]) { color: var(--danger); font-weight: 600; }

/* =====================================================================
   AUTH SCREENS
   ===================================================================== */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 12% 18%, rgba(42,169,176,.16), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(27,108,168,.16), transparent 42%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
}
.auth-logo {
  width: 64px; height: 64px; border-radius: 18px; object-fit: contain;
  display: block; margin: 0 auto .9rem; box-shadow: var(--shadow-sm);
  background: var(--surface); padding: 6px;
}
.auth-card h1 { text-align: center; font-size: 1.5rem; margin-bottom: .2rem; }
.auth-tagline { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-field { margin-bottom: 1rem; }
.auth-field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: #384250; }
.pw-wrap { position: relative; }
.pw-wrap .toggle-pw {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.pw-wrap .toggle-pw:hover { color: var(--text); background: var(--surface-2); }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin: .3rem 0 1.2rem; font-size: .85rem; }
.btn-block { width: 100%; }
.auth-alt { text-align: center; margin-top: 1.15rem; font-size: .9rem; color: var(--muted); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: .3rem; }

.btn-spinner {
  display: inline-block; width: 1em; height: 1em; border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: -2px; margin-right: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   PRINT
   ===================================================================== */
@media print {
  .admin-sidebar, .admin-topbar, .bottom-nav, .app-bar, .no-print { display: none !important; }
  .admin-main, .app-shell { margin: 0 !important; box-shadow: none !important; }
  .card { box-shadow: none !important; border-color: #ccc !important; }
  body { background: #fff !important; }
}

/* ---------- Install the app (pwa-install.js) ---------- */
[data-install-link][hidden], [data-install-banner][hidden] { display: none !important; }
.install-link { text-align: center; margin: 1rem 0 0; font-size: .92rem; font-weight: 600; }
.install-link a { text-decoration: none; }
.install-banner {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: .7rem .6rem .7rem .75rem; margin-bottom: 1rem;
}
.install-banner img { width: 40px; height: 40px; border-radius: var(--r-xs); flex-shrink: 0; }
.install-banner .ib-text { flex: 1; min-width: 0; line-height: 1.25; }
.install-banner .ib-text strong { display: block; font-size: .92rem; }
.install-banner .ib-text span { font-size: .8rem; color: var(--muted); }
.install-banner .ib-close {
  border: 0; background: none; color: var(--faint); font-size: 1.4rem; line-height: 1;
  padding: .1rem .35rem; flex-shrink: 0;
}
.install-guide ol { padding-left: 1.2rem; margin-bottom: .75rem; }
.install-guide li { margin-bottom: .6rem; }
.install-guide .ig-ico { display: inline-flex; vertical-align: -3px; margin-left: .2rem; color: var(--brand); }

/* Installing / installed screen (pwa-install.js) */
html.install-screen-open, html.install-screen-open body { overflow: hidden; }
.install-screen {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--bg);
  animation: is-fade .2s ease-out;
}
.install-screen .is-card { max-width: 340px; width: 100%; text-align: center; }
.install-screen .is-icon { position: relative; width: 112px; height: 112px; margin: 0 auto 1.4rem; }
.install-screen .is-icon img {
  position: absolute; inset: 16px; width: 80px; height: 80px;
  border-radius: 20px; box-shadow: var(--shadow);
}
.install-screen .is-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--brand);
  animation: is-spin .9s linear infinite;
}
.install-screen .is-check {
  position: absolute; right: 2px; bottom: 2px; width: 34px; height: 34px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: var(--success); color: #fff; font-size: 1rem;
  border: 3px solid var(--bg); animation: is-pop .3s ease-out;
}
.install-screen.is-done .is-ring { display: none; }
.install-screen.is-done .is-check { display: flex; }
.install-screen .is-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 .5rem; }
.install-screen .is-text { color: var(--muted); line-height: 1.5; margin: 0 0 1.25rem; }
.install-screen .is-continue { font-size: .9rem; color: var(--muted); }
@keyframes is-spin { to { transform: rotate(360deg); } }
@keyframes is-fade { from { opacity: 0; } }
@keyframes is-pop { from { transform: scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .install-screen, .install-screen .is-check { animation: none; }
  .install-screen .is-ring { animation-duration: 2.4s; }
}

/* In-app document viewer (doc-viewer.js) */
html.doc-viewer-open, html.doc-viewer-open body { overflow: hidden; }
.doc-viewer {
  position: fixed; inset: 0; z-index: 3100; display: none; flex-direction: column;
  background: rgba(10, 16, 24, .94);
}
.doc-viewer.show { display: flex; }
.doc-viewer .dv-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top)) .75rem .6rem;
  color: #fff; background: rgba(0, 0, 0, .35);
}
.doc-viewer .dv-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-viewer .dv-btn {
  display: inline-flex; align-items: center; gap: .4rem; flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; background: rgba(255, 255, 255, .12);
  color: #fff; font-size: .9rem; font-weight: 600; padding: .45rem .9rem; text-decoration: none; min-height: 40px;
}
.doc-viewer .dv-close { background: #fff; color: #111; border-color: #fff; }
.doc-viewer .dv-body {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom));
}
.doc-viewer .dv-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; }
.doc-viewer .dv-body iframe { width: 100%; height: 100%; border: 0; border-radius: 6px; background: #fff; }
.doc-viewer .dv-msg { color: #fff; text-align: center; }
.doc-viewer .dv-msg .fa-file-pdf { font-size: 3rem; margin-bottom: .75rem; color: #ff8a80; }
@media (max-width: 420px) { .doc-viewer .dv-download span { display: none; } }
