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

:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #fff7ed;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --red: #ef4444;
  --green: #22c55e;
  --radius: 12px;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

.screen {
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

/* ---------- Auth Screen ---------- */

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.logo {
  font-size: 48px;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: -1px;
  margin-bottom: 32px;
}

.auth-subtitle {
  color: var(--gray-500);
  margin-top: 4px;
  margin-bottom: 32px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.auth-form input {
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: var(--orange);
}

.check-email-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 16px;
  text-align: center;
}

.check-email-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  text-align: center;
  line-height: 1.4;
}

.check-email-note {
  font-size: 13px;
  color: var(--gray-400);
  text-align: center;
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  padding: 14px 20px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
}

.btn-primary:active:not(:disabled) {
  background: var(--orange-dark);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
}

.btn-small {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
}

.btn-link {
  background: transparent;
  color: var(--gray-500);
  font-size: 14px;
  padding: 8px;
  text-decoration: underline;
}

/* ---------- Error ---------- */

.error-msg {
  color: var(--red);
  font-size: 14px;
  text-align: center;
  padding: 8px 0;
}

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--orange);
}

.header-logo {
  max-height: 20px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  font-size: 13px;
  color: var(--gray-500);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Main ---------- */

main {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 40px;
}

/* ---------- Offline Banner ---------- */

.offline-banner {
  background: var(--gray-700);
  color: #fff;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---------- Balance Card ---------- */

.balance-card {
  background: var(--orange);
  color: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}

.balance-label {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.balance-value {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* ---------- Cards ---------- */

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--gray-900);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.form-row input {
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.form-row input:focus {
  border-color: var(--orange);
}

/* ---------- Nav Buttons ---------- */

.nav-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.nav-btn {
  width: 100%;
  text-align: center;
}

/* ---------- Page Header ---------- */

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.btn-back {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--gray-700);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 8px;
}

.btn-back:active {
  background: var(--gray-100);
}

/* ---------- Transactions ---------- */

.transactions-list {
  display: flex;
  flex-direction: column;
}

.empty-state {
  text-align: center;
  color: var(--gray-400);
  padding: 24px 0;
  font-size: 14px;
}

.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.tx-note {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-date {
  font-size: 12px;
  color: var(--gray-400);
}

.tx-amount {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: 12px;
}

.tx-amount.credit {
  color: var(--orange);
}

.tx-amount.debit {
  color: var(--gray-500);
}

/* ---------- Loading spinner on buttons ---------- */

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
