/* ============================================================
   LoanArchitect Pro — Premium FinTech CSS
   ============================================================ */

/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  --primary:        #6366f1;
  --primary-2:      #8b5cf6;
  --accent:         #06b6d4;
  --accent-2:       #10b981;
  --danger:         #f43f5e;
  --warning:        #f59e0b;
  --success:        #10b981;
  --info:           #8b5cf6;

  --bg:             #f0f4ff;
  --bg-2:           #e8eeff;
  --surface:        rgba(255,255,255,0.72);
  --surface-solid:  #ffffff;
  --border:         rgba(99,102,241,0.12);
  --border-hover:   rgba(99,102,241,0.3);

  --text:           #0f0c2e;
  --text-2:         #4c4888;
  --text-muted:     #7c7a9e;

  --nav-bg:         rgba(255,255,255,0.82);
  --input-bg:       rgba(240,244,255,0.9);

  --shadow-sm:      0 1px 3px rgba(99,102,241,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 20px rgba(99,102,241,0.12), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg:      0 16px 48px rgba(99,102,241,0.18), 0 8px 24px rgba(0,0,0,0.08);
  --shadow-glow:    0 0 40px rgba(99,102,241,0.25);

  --radius-sm:      0.5rem;
  --radius-md:      0.875rem;
  --radius-lg:      1.25rem;
  --radius-xl:      1.75rem;

  --transition:     0.25s cubic-bezier(0.4,0,0.2,1);
  --spring:         0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}

.dark {
  --primary:        #818cf8;
  --primary-2:      #a78bfa;
  --accent:         #22d3ee;
  --accent-2:       #34d399;

  --bg:             #07060f;
  --bg-2:           #0e0c1e;
  --surface:        rgba(255,255,255,0.045);
  --surface-solid:  #12101e;
  --border:         rgba(129,140,248,0.14);
  --border-hover:   rgba(129,140,248,0.35);

  --text:           #e8e6ff;
  --text-2:         #a5a3c8;
  --text-muted:     #6c6a90;

  --nav-bg:         rgba(10,8,22,0.88);
  --input-bg:       rgba(255,255,255,0.055);

  --shadow-md:      0 4px 20px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg:      0 16px 48px rgba(0,0,0,0.55), 0 8px 24px rgba(0,0,0,0.35);
  --shadow-glow:    0 0 60px rgba(129,140,248,0.2);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; }

/* ─── Base ───────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
  position: relative;
}

/* Animated mesh background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(139,92,246,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 60% 40%, rgba(6,182,212,0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: meshShift 12s ease-in-out infinite alternate;
}

.dark body::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(139,92,246,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 60% 40%, rgba(6,182,212,0.08) 0%, transparent 50%);
}

@keyframes meshShift {
  0%   { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0.7; transform: scale(1.05) rotate(1deg); }
}

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }

.text-primary  { color: var(--primary); }
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-info     { color: var(--info); }

/* ─── Layout ─────────────────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.25rem 1.75rem;
  position: relative;
  z-index: 1;
}

.flex            { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 0.5rem; }
.gap-4  { gap: 1rem; }
.gap-6  { gap: 1.5rem; }
.flex-col { flex-direction: column; }

/* ─── Header / Nav ───────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2.5rem;
  height: 72px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.4s ease;
}

/* Gradient line on top of header */
header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2), var(--accent));
  background-size: 200% 100%;
  animation: gradientSlide 4s linear infinite;
}

@keyframes gradientSlide {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  user-select: none;
}

.brand-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(99,102,241,0.45);
  transition: transform var(--transition), box-shadow var(--transition);
}
.brand-icon:hover { transform: rotate(-6deg) scale(1.08); box-shadow: var(--shadow-glow); }

.brand-text {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.brand-text span {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  position: relative;
  letter-spacing: 0.01em;
}
.nav-btn::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 50%; right: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 99px;
  transition: left var(--transition), right var(--transition);
}
.nav-btn:hover { color: var(--text); background: rgba(99,102,241,0.07); }
.nav-btn.active {
  color: var(--primary);
  background: rgba(99,102,241,0.1);
  font-weight: 600;
}
.nav-btn.active::after { left: 12%; right: 12%; }

.header-right { display: flex; align-items: center; gap: 0.75rem; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1.1rem;
}
.icon-btn:hover {
  background: rgba(99,102,241,0.1);
  border-color: var(--border-hover);
  color: var(--primary);
  transform: scale(1.05);
}

/* ─── Glass Card ─────────────────────────────────────────── */
.glass-card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.glass-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}

/* ─── Tab System ─────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: tabSlideIn 0.45s cubic-bezier(0.22,1,0.36,1) forwards;
}

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

/* ─── Section Header ─────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.section-title  { font-size: 1.625rem; font-weight: 800; letter-spacing: -0.5px; }
.section-sub    { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; font-weight: 400; }
.section-actions { display: flex; gap: 0.625rem; align-items: center; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

/* Ripple effect base */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s, transform 0.4s;
}
.btn:active::after { opacity: 1; transform: scale(2); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.38), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.45);
  filter: brightness(1.06);
}
.btn-primary:active { transform: translateY(0); }

.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: white;
  box-shadow: 0 4px 16px rgba(16,185,129,0.35);
}
.btn-success:hover { transform: translateY(-2px); filter: brightness(1.06); }

.btn-danger-outline {
  background: rgba(244,63,94,0.08);
  color: var(--danger);
  border: 1px solid rgba(244,63,94,0.2);
}
.btn-danger-outline:hover {
  background: rgba(244,63,94,0.15);
  border-color: rgba(244,63,94,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--input-bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(99,102,241,0.07);
  border-color: var(--border-hover);
  color: var(--primary);
}

.btn-lg { padding: 0.875rem 1.5rem; font-size: 0.95rem; border-radius: var(--radius-md); }
.btn-full { width: 100%; }

/* ─── Dashboard Stats Grid ───────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.125rem;
  margin-bottom: 1.75rem;
}

@media (min-width: 640px)  { .dashboard-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .dashboard-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.375rem;
  overflow: hidden;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.stat-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.stat-icon.blue   { background: rgba(99,102,241,0.12); color: var(--primary); }
.stat-icon.green  { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: var(--primary-2); }
.stat-icon.cyan   { background: rgba(6,182,212,0.12);  color: var(--accent); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Featured dark card */
.stat-card.featured {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #6366f1 100%);
  border: none;
  color: white;
}
.dark .stat-card.featured {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
}
.stat-card.featured .stat-label  { color: rgba(255,255,255,0.65); }
.stat-card.featured .stat-value  { color: white; }
.stat-card.featured .stat-trend  { color: rgba(255,255,255,0.7); }
.stat-card.featured::before      { background: radial-gradient(ellipse at top right, rgba(255,255,255,0.15) 0%, transparent 60%); }

/* Orb decoration in featured card */
.stat-card.featured::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}

/* ─── Table ──────────────────────────────────────────────── */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; text-align: left; }

th {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(99,102,241,0.04); }

/* ─── Form Inputs ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }

.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
  caret-color: var(--primary);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
  border-color: var(--primary);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3.5px rgba(99,102,241,0.15), 0 1px 8px rgba(99,102,241,0.12);
}

.input-with-icon { position: relative; }
.input-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}
.input-with-icon .form-input { padding-left: 2.6rem; }

textarea.form-input { resize: none; min-height: 70px; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7,6,15,0.55);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-backdrop.active {
  display: flex;
  animation: backdropIn 0.3s ease forwards;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--surface-solid);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  transform: scale(0.88) translateY(30px);
  opacity: 0;
  transition: all var(--spring);
  overflow: hidden;
  position: relative;
}
.modal-backdrop.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Gradient stripe at the top */
.modal-content::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2), var(--accent));
  background-size: 200% 100%;
  animation: gradientSlide 3s linear infinite;
}

.modal-header {
  padding: 1.375rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-body {
  padding: 1.5rem;
  max-height: 78vh;
  overflow-y: auto;
}

/* ─── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: -120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.375rem;
  border-radius: 2rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.84rem;
  font-weight: 600;
  z-index: 1000;
  white-space: nowrap;
  background: rgba(15,13,30,0.92);
  color: #f1f0ff;
  border: 1px solid rgba(129,140,248,0.25);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.05);
  transition: bottom 0.45s cubic-bezier(0.175,0.885,0.32,1.275);
}
.dark .toast-container {
  background: rgba(240,244,255,0.92);
  color: #0f0c2e;
  border-color: rgba(99,102,241,0.25);
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
}
.toast-container.show { bottom: 2rem; }

/* ─── Loans Grid ─────────────────────────────────────────── */
.loans-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 900px) { .loans-grid { grid-template-columns: repeat(2, 1fr); } }

/* Loan card animate in via JS addition */
.loan-card-enter {
  animation: loanCardIn 0.5s cubic-bezier(0.22,1,0.36,1) forwards;
}
@keyframes loanCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);     }
}

/* Delete button */
.loan-card-delete {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: all var(--transition);
  font-size: 1rem;
}
.glass-card:hover .loan-card-delete { opacity: 1; }
.loan-card-delete:hover {
  background: rgba(244,63,94,0.1);
  color: var(--danger);
  transform: scale(1.1);
}

/* Avatar */
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Loan detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
  margin: 1.125rem 0;
}
.detail-item { display: flex; flex-direction: column; gap: 0.2rem; }
.detail-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.detail-value { font-weight: 700; font-size: 0.9rem; color: var(--text); }

/* Divider */
.hr {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Progress bar for repayment */
.repay-progress-bar {
  height: 5px;
  width: 100%;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.repay-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent-2));
  transition: width 0.6s cubic-bezier(0.22,1,0.36,1);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-danger  { background: rgba(244,63,94,0.1);  color: var(--danger);  }
.badge-success { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-purple  { background: rgba(139,92,246,0.1); color: var(--primary-2); }

/* Balance info card inside repayment modal */
.balance-info-box {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.balance-info-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.balance-info-value { font-size: 1.1rem; font-weight: 800; color: var(--primary); }

/* ─── Grouped Borrower Card ──────────────────────────────── */
.loans-list { display: flex; flex-direction: column; gap: 1.25rem; }

/* Individual loan entry row inside a borrower card */
.loan-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: background var(--transition), border-color var(--transition);
  flex-wrap: wrap;
}
.loan-entry-row:last-child { margin-bottom: 0; }
.loan-entry-row:hover {
  background: rgba(99,102,241,0.04);
  border-color: var(--border-hover);
}

.loan-entry-fields {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.loan-entry-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

/* Small numbered badge per entry */
.entry-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(99,102,241,0.12);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 800;
  flex-shrink: 0; margin-top: 2px;
}

/* Inline delete button inside an entry row */
.entry-delete-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.loan-entry-row:hover .entry-delete-btn { opacity: 1; }
.entry-delete-btn:hover {
  background: rgba(244,63,94,0.1);
  border-color: rgba(244,63,94,0.25);
  color: var(--danger);
}

/* Borrower-level totals row */
.borrower-totals {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.loan-balance-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.loan-balance-label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.15rem; }
.loan-balance-value { font-size: 1.25rem; font-weight: 900; color: var(--text); }

/* ─── Mobile Nav ─────────────────────────────────────────── */
.mobile-nav { display: none; }

@media (max-width: 767px) {
  header { padding: 0 1rem; height: 60px; }
  .nav-links { display: none; }
  .btn.desktop-only { display: none; }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 0.2rem;
    padding: 0.75rem 0;
    color: var(--text-muted);
    background: none;
    border: none;
    font-size: 0.6rem;
    font-weight: 600;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color var(--transition);
    position: relative;
  }
  .mobile-nav-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 25%; right: 25%;
    height: 2px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    opacity: 0;
    transition: opacity var(--transition);
  }
  .mobile-nav-btn.active { color: var(--primary); }
  .mobile-nav-btn.active::before { opacity: 1; }

  .toast-container.show { bottom: 5.5rem; }

  .container {
    padding: 1.5rem 1rem 6rem;
  }

  .section-title { font-size: 1.3rem; }
  .stat-value { font-size: 1.45rem; }
}

/* ─── FAB ────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed;
  bottom: 5.5rem; right: 1.25rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 8px 28px rgba(99,102,241,0.5), 0 4px 12px rgba(0,0,0,0.15);
  border: none;
  align-items: center; justify-content: center;
  font-size: 1.4rem;
  z-index: 40;
  cursor: pointer;
  transition: all var(--transition);
}
.fab:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 12px 36px rgba(99,102,241,0.6); }
.fab:active { transform: scale(0.95); }

@media (max-width: 767px) {
  .fab.active { display: flex; }
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  gap: 0.75rem;
}
.empty-icon-wrap {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.08));
  border: 1px solid rgba(99,102,241,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  animation: floatBob 3s ease-in-out infinite;
}
@keyframes floatBob {
  0%, 100% { transform: translateY(0);   }
  50%       { transform: translateY(-8px); }
}
.empty-state h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.empty-state p  { color: var(--text-muted); font-size: 0.875rem; max-width: 240px; }

/* ─── History Section ────────────────────────────────────── */
.history-row-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.12));
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(99,102,241,0.08) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── Animated number counter ────────────────────────────── */
.stat-value[data-animate] { transition: all 0.5s ease; }

/* ─── Utility overrides ──────────────────────────────────── */
button { font-family: inherit; }
a { text-decoration: none; }
strong { font-weight: 700; }

/* ─── Loan detail — balance footer ───────────────────────── */
.loan-balance-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.loan-balance-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.loan-balance-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
