/* Co-Lend Hub Premium Design System */

:root {
  /* Brand palette — matches the Bazaar Trust logo (burgundy + gold) */
  --primary-hue: 355;
  --primary-sat: 56%;
  --primary-light: 28%;

  --theme-primary: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
  --theme-primary-hover: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 8%));
  --theme-primary-light: hsl(var(--primary-hue), var(--primary-sat), 96%);
  --theme-primary-glow: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.15);

  --color-gold: #c9a24b;
  --color-gold-hover: #b58f3c;

  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --bg-app: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-color: rgba(226, 232, 240, 0.8);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.06);

  --color-green: #10b981;
  --color-blue: #3b82f6;
  --color-purple: #8b5cf6;
  --color-red: #ef4444;
  --color-orange: #f97316;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  font-family: var(--font-sans);
  color: var(--text-main);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url('/static/logo.png');
  background-repeat: no-repeat;
  background-position: center 42vh;
  background-size: min(65vw, 440px);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

.app-container,
.admin-container {
  position: relative;
  z-index: 1;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Base Classes */
.hidden {
  display: none !important;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--color-red) !important; }
.text-success { color: var(--color-green) !important; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.my-3 { margin: 1rem 0; }
.my-4 { margin: 1.5rem 0; }
.border-left { border-left: 1px solid var(--border-color); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary {
  background-color: var(--theme-primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--theme-primary-hover);
  box-shadow: 0 4px 12px var(--theme-primary-glow);
}
.btn-secondary {
  background-color: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
}
.btn-danger {
  background-color: var(--color-red);
  color: #fff;
}
.btn-danger:hover {
  background-color: #dc2626;
}
.btn-success {
  background-color: var(--color-green);
  color: #fff;
}
.btn-success:hover {
  background-color: #059669;
}
.btn-warning {
  background-color: var(--color-orange);
  color: #fff;
}
.btn-warning:hover {
  background-color: #ea580c;
}
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-main);
}
.btn-icon:hover {
  background: #f1f5f9;
}
.btn-icon-text {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
}
.btn-icon-text:hover {
  background: #f1f5f9;
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}
.required-asterisk {
  color: var(--color-red);
}

/* Clickable star rating picker */
.star-picker {
  display: flex;
  gap: 0.5rem;
  font-size: 1.75rem;
  line-height: 1;
}
.star-picker-icon {
  color: #e2e8f0;
  cursor: pointer;
  transition: color 0.12s ease, transform 0.1s ease;
}
.star-picker-icon:hover {
  transform: scale(1.15);
}
.star-picker-icon.active {
  color: var(--color-gold);
}
.form-control, .form-select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: #fff;
  transition: all 0.2s;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

/* Password update card */
.password-card {
  margin-top: 1.5rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--theme-primary-light) 0%, rgba(255,255,255,0.4) 100%);
  padding: 1.1rem 1.1rem 1.25rem;
}
.password-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.password-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--theme-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px var(--theme-primary-glow);
  flex-shrink: 0;
}
.password-card-header h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}
.password-card-header p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .form-control {
  padding-left: 2.5rem;
  padding-right: 2.5rem;
  background-color: #fff;
}
.input-with-icon .input-lead-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.input-with-icon .input-toggle-icon {
  position: absolute;
  right: 0.9rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem;
}
.input-with-icon .input-toggle-icon:hover {
  color: var(--theme-primary);
}
.password-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 75px; /* bottom nav padding */
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1rem;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--theme-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px var(--theme-primary-glow);
  transition: background 0.3s;
}
.brand-logo-img {
  background: none;
  border-radius: 50%;
  box-shadow: none;
  overflow: hidden;
}
.brand-logo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}
.brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* KPIs Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  padding: 1rem;
}
.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
}
.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.color-green { background: #e6f7ed; color: var(--color-green); }
.color-blue { background: #eff6ff; color: var(--color-blue); }
.color-purple { background: #f5f3ff; color: var(--color-purple); }
.color-red { background: #fef2f2; color: var(--color-red); }

.kpi-info {
  display: flex;
  flex-direction: column;
}
.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-info h3 {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.1rem 0;
}
.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* App Main */
.app-main {
  flex: 1;
  padding: 0 1rem;
}

/* Tabs */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}
.tab-pane.active {
  display: block;
}

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

/* Directory Layout (Master-Detail) */
.controls-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.search-box {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.8rem;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.search-box:focus-within {
  background: #fff;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.search-box i {
  color: var(--text-muted);
  margin-right: 0.6rem;
}
.search-box input {
  background: transparent;
  border: none;
  width: 100%;
  outline: none;
  font-family: var(--font-sans);
  color: var(--text-main);
  font-size: 0.9rem;
}
.filter-row {
  display: flex;
  gap: 0.6rem;
}
.filter-row select {
  flex: 1;
}

/* Ledger Layout Grid */
.ledger-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  min-height: 500px;
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 600px;
  overflow-y: auto;
}

/* Borrower Cards in List */
.borrower-list-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.borrower-list-card:hover {
  border-color: var(--theme-primary);
  transform: translateX(2px);
}
.borrower-list-card.active {
  border-color: var(--theme-primary);
  background-color: var(--theme-primary-light);
  box-shadow: 0 2px 10px var(--theme-primary-glow);
}
.borrower-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}
.borrower-card-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
}
.trust-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}
.badge-excellent { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-critical { background: #fee2e2; color: #b91c1c; }

.borrower-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.borrower-card-meta span i {
  width: 14px;
  margin-right: 0.3rem;
}

/* Empty State / Profiles Sheet */
.profile-detail-panel {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 90px;
}

/* Scroll to Top Button */
.scroll-top-btn {
  position: fixed;
  right: 1rem;
  bottom: 80px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--theme-primary);
  color: #fff;
  font-size: 1.05rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 95;
  transition: opacity 0.2s, transform 0.2s;
}
.scroll-top-btn:hover {
  background: var(--theme-primary-hover);
}
.scroll-top-btn.hidden {
  display: none;
}
.empty-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 350px;
  color: var(--text-muted);
  text-align: center;
  gap: 1rem;
}
.empty-prompt i {
  font-size: 3rem;
  color: #cbd5e1;
}

/* Profile Details Layout */
.profile-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.2rem;
}
.profile-sheet-identity {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}
.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--theme-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--theme-primary-glow);
}
.profile-sheet-title {
  min-width: 0;
}
.profile-sheet-title h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.profile-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.profile-contact-row span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.profile-contact-row i {
  width: 14px;
  margin-right: 0.35rem;
  color: var(--text-muted);
}
.profile-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}
.metric-box {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.metric-box span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.metric-box strong {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
}

.profile-section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Collapsible Agreement Cards */
.agreement-card {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #fff;
  margin-bottom: 0.8rem;
  overflow: hidden;
}
.agreement-card-summary {
  padding: 0.8rem 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
}
.agreement-card-summary:hover {
  background: #f5f5f5;
}
.agreement-status-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-weight: 600;
}
.agreement-status-active { background: #dbeafe; color: #1e40af; }
.agreement-status-fully_paid { background: #dcfce7; color: #166534; }
.agreement-status-defaulted { background: #fee2e2; color: #991b1b; }

.agreement-card-details {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}
.collateral-pill {
  background: #fafaf9;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
}
.collateral-pill strong {
  color: var(--theme-primary);
}

/* Installments List */
.installments-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.installment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: 0.8rem;
}
.inst-due-date {
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.inst-amount-box {
  font-family: var(--font-mono);
  font-weight: 600;
}
.inst-status-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}
.inst-status-pending { background: #f1f5f9; color: #475569; }
.inst-status-paid { background: #dcfce7; color: #15803d; }
.inst-status-late { background: #fee2e2; color: #b91c1c; }
.inst-status-settled_kind { background: #fef3c7; color: #d97706; }
.inst-status-written_off { background: #f3e8ff; color: #7e22ce; }
.inst-status-pending_whatsapp { background: #ecfdf5; color: #047857; }
.inst-status-partially_paid { background: #ffedd5; color: #c2410c; }

.inst-actions {
  display: flex;
  gap: 0.4rem;
}

/* Traditional Register Table */
.table-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}
.data-table th, .data-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td[style*="pre-wrap"] {
  white-space: normal;
  min-width: 260px;
  max-width: 320px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.data-table tbody tr:hover {
  background: #fdfdfd;
}
.tx-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}
.debit-amt {
  color: var(--color-red);
  font-family: var(--font-mono);
}
.credit-amt {
  color: var(--color-green);
  font-family: var(--font-mono);
}
.fee-amt {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-card {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  animation: modalScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
}
@keyframes modalScale {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-body {
  padding: 1.2rem;
  overflow-y: auto;
}

/* Bottom Nav bar */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0.4rem 0.2rem;
  z-index: 90;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.4rem;
  border-radius: 12px;
  transition: all 0.2s;
  gap: 0.2rem;
}
.nav-item i {
  font-size: 1.2rem;
}
.nav-item span {
  font-size: 0.65rem;
  font-weight: 500;
}
.nav-item:hover {
  color: var(--text-main);
}
.nav-item.active {
  color: var(--theme-primary);
}

/* Interest rate period toggle (Monthly / Annually) */
.rate-period-toggle {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
  margin-top: 0.5rem;
}
.rate-period-btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fff;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rate-period-btn + .rate-period-btn {
  border-left: 1px solid var(--border-color);
}
.rate-period-btn.active {
  background: var(--theme-primary);
  color: #fff;
}
.field-hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Secured Loan toggle — deliberately prominent so it isn't missed */
.secured-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 1.25rem 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.secured-toggle-card.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--color-green);
}
.secured-toggle-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.secured-toggle-icon {
  font-size: 1.3rem;
  color: var(--text-muted);
  flex: none;
  transition: color 0.2s ease;
}
.secured-toggle-card.active .secured-toggle-icon {
  color: var(--color-green);
}
.secured-toggle-info strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: color 0.2s ease;
}
.secured-toggle-card.active .secured-toggle-info strong {
  color: var(--color-green);
}
.secured-toggle-info .field-hint {
  margin-top: 0.15rem;
}

/* Checkbox design */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-container input {
  display: none;
}
.checkmark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: inline-block;
  position: relative;
  background: #fff;
  transition: all 0.2s;
}
.checkbox-container input:checked ~ .checkmark {
  background: var(--theme-primary);
  border-color: var(--theme-primary);
}
.checkbox-container input:checked ~ .checkmark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Payment Tabs Header */
.payment-tabs-header {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.25rem;
  margin: 0.5rem 0 0.8rem 0;
  gap: 0.25rem;
}
.pay-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.6rem 0.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}
.pay-tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.02);
}
.pay-tab-btn.active {
  background: var(--theme-primary);
  color: #ffffff;
}

/* Payment Modal Grid */
.payment-method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0.8rem 0;
}
.method-option {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem 0.4rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.method-option i {
  font-size: 1.25rem;
  color: var(--text-muted);
}
.method-option span {
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.2;
}
.method-option:hover {
  border-color: var(--theme-primary);
}
.method-option.active {
  background-color: var(--theme-primary-light);
  border-color: var(--theme-primary);
}
.method-option.active i {
  color: var(--theme-primary);
}

/* Payment amount radio options (Paid in Full / Partial Payment) */
.payment-amount-options {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.payment-amount-options .pay-amount-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
}
.pay-amount-option input {
  display: none;
}
.pay-amount-option:hover {
  border-color: var(--theme-primary);
  transform: translateY(-1px);
}
.pay-amount-option.active {
  background-color: var(--theme-primary-light);
  border-color: var(--theme-primary);
  box-shadow: 0 4px 16px var(--theme-primary-glow);
}
.pay-amount-option-icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  background: #f1f5f9;
  color: var(--text-muted);
  transition: all 0.18s ease;
}
.pay-amount-option.active .pay-amount-option-icon {
  background: var(--theme-primary);
  color: #fff;
}
.pay-amount-option-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.pay-amount-option-text strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}
.pay-amount-option-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.pay-amount-check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}
.pay-amount-check i {
  font-size: 0.65rem;
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition: all 0.18s ease;
}
.pay-amount-option.active .pay-amount-check {
  border-color: var(--theme-primary);
  background: var(--theme-primary);
}
.pay-amount-option.active .pay-amount-check i {
  opacity: 1;
  transform: scale(1);
}

/* ₹-prefixed amount input */
.amount-input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s;
}
.amount-input-prefix:focus-within {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.amount-prefix-symbol {
  display: flex;
  align-items: center;
  padding: 0 0.9rem;
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  border-right: 1px solid var(--border-color);
}
.amount-input-prefix .form-control {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}

/* Cash Denomination Counters */
.cash-denoms-container {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}
.denom-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.denom-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
.denom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
}
.counter-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.counter-box button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.denom-sum-row {
  display: flex;
  justify-content: flex-end;
  font-size: 0.8rem;
  margin-top: 0.6rem;
  border-top: 1px dotted var(--border-color);
  padding-top: 0.4rem;
}

/* QR Gate Simulator */
.sim-qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem 0;
}
.qr-box {
  background: #fff;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: center;
  align-items: center;
}
.qr-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.8rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 10001;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
}
.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
}

/* Global Loading Overlay */
.global-loader-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: #fff;
}
.global-loader-spinner i {
  font-size: 2.6rem;
  color: #10b981;
}
.global-loader-spinner p {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

/* Suspension Lockout Screen CSS */
.overlay-lock {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.lock-card {
  background: #fff;
  border-radius: 24px;
  max-width: 440px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: lockBounce 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes lockBounce {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.lock-icon {
  font-size: 3rem;
  color: var(--color-red);
  margin-bottom: 1.2rem;
}
.lock-card h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.lock-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.dues-summary-card {
  background: #fee2e2;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.due-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #991b1b;
}
.due-row strong {
  font-family: var(--font-mono);
  font-size: 1.2rem;
}
.upi-apps-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.upi-app-btn {
  flex: 1;
  border: 1px solid var(--border-color);
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.upi-app-btn.active {
  background: var(--theme-primary-light);
  border-color: var(--theme-primary);
  color: var(--theme-primary);
}

.fee-overdue-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 1px solid #fecaca;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.fee-overdue-banner:hover {
  background: #fee2e2;
}
.fee-overdue-banner-cta {
  font-weight: 700;
  text-decoration: underline;
}

.lockout-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Switch Toggle slider */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
.toggle-switch input:checked + .slider {
  background-color: var(--color-green);
}
.toggle-switch input:checked + .slider:before {
  transform: translateX(14px);
}

/* Layout adjustments for Planner的结果 and Register filtering */
.planner-layout, .ledger-layout {
  animation: fadeIn 0.3s ease;
}
.summary-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0.8rem 0;
}
.summary-kpi-item {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.6rem 0.4rem;
  display: flex;
  flex-direction: column;
  text-align: center;
}
.summary-kpi-item span {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.summary-kpi-item strong {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}
.issue-action-box {
  background: #fafaf9;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
}
.issue-action-box label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.issue-row {
  display: flex;
  gap: 0.5rem;
}
.issue-row select {
  flex: 1;
}

.filter-grid-register {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.6rem;
  width: 100%;
}

/* Community feed reviews styling */
.feed-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem 0;
}
.review-feed-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.review-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}
.lender-badge-info h5 {
  font-size: 0.95rem;
  font-weight: 600;
}
.review-date-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}
.stars-row {
  display: flex;
  gap: 0.15rem;
  color: #eab308;
  font-size: 0.8rem;
  margin: 0.2rem 0;
}
.review-feedback-text {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.4;
  margin-top: 0.4rem;
  background: #f8fafc;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
}

/* Profile modal tabs */
.profile-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  background: #fafafa;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn.active {
  color: var(--theme-primary);
  border-bottom-color: var(--theme-primary);
}
.profile-tab-pane {
  display: none;
}
.profile-tab-pane.active {
  display: block;
}

/* Platform fees items list style */
.fee-totals-card {
  display: flex;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem;
}
.total-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.total-col span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.total-col strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
}

.fee-periods-container {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.fee-period-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
  padding: 0.6rem 0.8rem;
}
.fee-period-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.fee-period-details {
  border-top: 1px dashed var(--border-color);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  font-size: 0.75rem;
}
.fee-tx-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.fee-tx-repayment {
  color: #15803d;
  font-weight: 600;
  border-top: 1px dashed var(--border-color);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}
.payment-loader {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}

.reminder-loader-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--theme-primary);
  font-weight: 500;
  font-size: 0.9rem;
}

.reminder-result-card {
  border: 1px solid var(--theme-primary);
  background: var(--theme-primary-light);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}
.reminder-result-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--theme-primary);
}
.reminder-result-card p {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-main);
  white-space: pre-wrap;
  margin-bottom: 0.8rem;
}
.reminder-action-bar {
  display: flex;
  justify-content: flex-end;
}

.remind-lang-btn.active {
  background: var(--theme-primary);
  border-color: var(--theme-primary);
  color: #fff;
}

/* RESPONSIVE DESIGN - MOBILE FIRST LAYOUT */
@media (max-width: 768px) {
  .ledger-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  
  .borrowers-list-panel {
    max-height: 300px;
    overflow-y: auto;
  }
  
  .profile-detail-panel {
    padding: 1rem;
  }

  .profile-sheet-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .inst-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
  }

  .inst-actions .btn {
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.3rem;
    font-size: 0.7rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }

  .inst-actions .btn i {
    font-size: 1rem;
  }

  .filter-grid-register {
    grid-template-columns: 1fr;
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-row select,
  .filter-row .btn {
    width: 100%;
  }

  .planner-layout {
    grid-template-columns: 1fr;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0.6rem;
    gap: 0.6rem;
  }
  .kpi-card {
    padding: 0.6rem;
    border-radius: 12px;
  }
  .kpi-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .kpi-info h3 {
    font-size: 1rem;
  }

  .brand p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
  }
}

/* Payment Modal Step Panes */
.payment-step-pane {
  display: none;
}
.payment-step-pane.active {
  display: block;
}

/* Platform Fee Payment Step Panes */
.fee-step-pane {
  display: none;
}
.fee-step-pane.active {
  display: block;
}

/* Simulated Time Badge inside Top Header Action Row */
.header-sim-badge {
  background-color: var(--color-orange);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.25);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-sim-badge:hover {
  background-color: #ea580c;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(249, 115, 22, 0.35);
}

/* Modal Pane Toggling for Time Simulator tab */
#p-tab-pane-simulator {
  display: none;
}
#p-tab-pane-simulator.active {
  display: block;
}

/* Custom Multi-select Dropdown styling */
.multiselect-wrapper {
  position: relative;
  width: 100%;
}
.multiselect-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  max-height: 250px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  margin-top: 6px;
  padding: 0.5rem;
}
.multiselect-dropdown.hidden {
  display: none;
}
.multiselect-search-container {
  padding: 0.25rem 0.25rem 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}
.multiselect-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}
.multiselect-search-input:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.multiselect-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.multiselect-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color 0.15s;
  user-select: none;
}
.multiselect-item:hover {
  background-color: var(--theme-primary-light);
}
.multiselect-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--theme-primary);
  cursor: pointer;
}

