:root {
  --primary: #2563eb;
  --primary-light: #60a5fa;
  --primary-dark: #1d4ed8;
  --secondary: #f59e0b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --border: #e2e8f0;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--background);
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 24px 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(248, 250, 252, 0.8);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 18px;
  box-shadow: var(--shadow-md);
}

/* Back Button Header */
.nav-header {
  padding: 20px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(12px);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: opacity 0.2s;
}

.back-btn:active {
  opacity: 0.5;
}

.nav-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-align: center;
  margin-right: 24px; /* balance out back button */
}

/* Main Dashboard Card */
.dashboard-card {
  margin: 16px 20px;
  padding: 28px 24px;
  background: linear-gradient(135deg, #1e3a8a, var(--primary));
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: 0 12px 24px -8px var(--primary);
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.dashboard-card::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.card-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.card-amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
}

.card-amount span {
  font-size: 20px;
  font-weight: 600;
  margin-right: 4px;
}

.card-stats {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
}

/* Quick Actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 0 20px 24px;
}

.action-btn {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.action-btn:hover, .action-btn:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.icon-blue { background: #eff6ff; color: var(--primary); }
.icon-orange { background: #fffbeb; color: var(--secondary); }
.icon-green { background: #ecfdf5; color: var(--success); }
.icon-red { background: #fef2f2; color: var(--danger); }

.action-label {
  font-size: 14px;
  font-weight: 600;
}

/* Recent Activity Section */
.section {
  padding: 24px 20px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
}

.view-all {
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

/* Loan List */
.loan-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px 24px;
  flex: 1;
}

.loan-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.loan-item:active {
  transform: scale(0.98);
}

.loan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 12px;
}

.loan-title {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.loan-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-active {
  background: #ecfdf5;
  color: var(--success);
}

.status-completed {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.status-pending {
  background: #fffbeb;
  color: var(--secondary);
}

.loan-details {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.detail-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-group.right {
  text-align: right;
}

.detail-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-date {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  padding: 0 20px 16px;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}

.filter-tabs::-webkit-scrollbar {
  display: none; /* Safari/Chrome */
}

.filter-tab {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
  opacity: 0;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-text {
  font-size: 16px;
  font-weight: 500;
}

/* Bottom Nav Bar */
.bottom-nav {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 10px rgba(0,0,0,0.02);
  z-index: 10;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  margin-top: auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item i {
  font-size: 20px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  color: var(--text-primary);
  font-family: inherit;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
  color: #94a3b8;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:active {
  background: var(--primary-dark);
  transform: translateY(1px);
}

.btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.amount-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.amount-input-prefix {
  position: absolute;
  left: 16px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-control.amount-input {
  padding-left: 44px;
  font-size: 28px;
  font-weight: 700;
  height: 72px;
}
