
:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --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);
  --radius: 12px;
  --radius-lg: 16px;
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Hind Siliguri', sans-serif;
  --nav-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + 20px);
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Loading Overlay */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 20px;
}
.auth-container {
  background: var(--surface);
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: fadeUp 0.5s ease;
}
.auth-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
  object-fit: cover;
}
.auth-header h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.auth-header p { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.9rem; }

.input-group { text-align: left; margin-bottom: 16px; }
.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--bg);
  font-family: var(--font-body);
}
.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  font-family: var(--font-body);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-body);
}
.auth-switch { margin-top: 20px; font-size: 0.85rem; color: var(--text-secondary); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
  background: #fef2f2;
  padding: 8px;
  border-radius: 8px;
  text-align: left;
}
.hidden { display: none !important; }

/* App Layout */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}
.nav-brand img { width: 32px; height: 32px; border-radius: 8px; }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--surface-hover); }
.badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 10px;
  min-width: 14px;
  text-align: center;
}

.dashboard {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
  flex: 1;
}

.view { display: none; animation: fadeUp 0.3s ease; }
.view.active { display: block; }

/* Home View */
.balance-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.balance-label { font-size: 0.9rem; opacity: 0.8; margin-bottom: 8px; }
.amount {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.sub-amount { font-size: 0.9rem; opacity: 0.7; margin-bottom: 12px; }
.rate-badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s;
  font-family: var(--font-body);
  font-size: 0.8rem;
}
.action-btn:hover { background: var(--surface-hover); border-color: var(--accent); transform: translateY(-2px); }
.action-btn .icon { font-size: 1.5rem; margin-bottom: 4px; }

/* History View */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}
.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}
.tx-list { display: flex; flex-direction: column; gap: 10px; }
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.tx-info h4 { font-weight: 600; margin-bottom: 4px; font-size: 0.95rem; }
.tx-meta { font-size: 0.75rem; color: var(--text-muted); }
.tx-amount { font-weight: 700; font-family: var(--font-heading); font-size: 1rem; }
.tx-amount.positive { color: var(--success); }
.tx-amount.negative { color: var(--danger); }
.status-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
  display: inline-block;
}
.status-pending { background: #fef3c7; color: #b45309; }
.status-success { background: #d1fae5; color: #047857; }
.status-rejected { background: #fee2e2; color: #b91c1c; }
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-style: italic;
}

/* Profile View */
.profile-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.avatar {
  width: 64px; height: 64px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  margin: 0 auto 12px;
}
.profile-card h3 { font-family: var(--font-heading); margin-bottom: 4px; }
.profile-card p { color: var(--text-secondary); margin-bottom: 12px; font-size: 0.9rem; }
.profile-meta { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.tag {
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.status-active { background: #d1fae5; color: #047857; }

/* Admin */
#admin-panel { margin-top: 24px; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.tab {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font-body);
}
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.user-card {
  background: var(--surface);
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.user-card h4 { margin-bottom: 4px; font-size: 0.9rem; }
.user-card p { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 10px; }
.user-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-body);
}
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }

.settings-card { max-width: 100%; }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 16px;
  transition: all 0.2s;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke-width: 2.5; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-family: var(--font-heading); font-weight: 700; }
.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-form p { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.9rem; }

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

@media (max-width: 480px) {
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .amount { font-size: 2rem; }
  .balance-card { padding: 20px; }
}
