/* ============================================================
   THE MURRAY MISSION — Design System v2.0
   Colors, typography, 3D cards, frosted glass, animations,
   components, dark mode — comprehensive visual system
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Backgrounds */
  --bg: #FFFFFF;
  --bg-dark: #111111;
  --surface: #F4F4F4;
  --surface-dark: #1C1C1E;
  --warm-surface: #FAF8F4;
  --warm-surface-dark: #1A1A1A;

  /* Text */
  --text-primary: #111111;
  --text-primary-dark: #F5F5F5;
  --text-muted: #6B7280;

  /* Accent */
  --accent: #DC7327;
  --accent-hover: #C5661F;

  /* Money */
  --money: #1A7A4A;
  --money-bg: #D1FAE5;

  /* Warning */
  --warning: #B45309;
  --warning-bg: #FEF3C7;

  /* Danger */
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;

  /* Layout */
  --radius: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12), 0 8px 32px rgba(0,0,0,0.08);
  --min-tap: 48px;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --fs-xs: 12px;
  --fs-label: 13px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --fs-3xl: 40px;
  --fs-hero: 48px;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 20px;
  --sp-2xl: 24px;
  --sp-3xl: 32px;
  --sp-4xl: 40px;

  /* Active colors (light mode) */
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-warm-surface: var(--warm-surface);
  --color-text: var(--text-primary);
  --color-text-inverse: var(--text-primary-dark);

  /* Card borders */
  --card-border: rgba(0,0,0,0.06);

  /* Frosted glass */
  --glass-bg: rgba(255,255,255,0.85);
  --glass-border: rgba(0,0,0,0.06);
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: var(--bg-dark);
    --color-surface: var(--surface-dark);
    --color-warm-surface: var(--warm-surface-dark);
    --color-text: var(--text-primary-dark);
    --color-text-inverse: var(--text-primary);
    --card-border: rgba(255,255,255,0.08);
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.25), 0 8px 24px rgba(0,0,0,0.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.2);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.3), 0 8px 32px rgba(0,0,0,0.2);
    --glass-bg: rgba(17,17,17,0.85);
    --glass-border: rgba(255,255,255,0.06);
  }
}

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

html {
  font-size: var(--fs-base);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}
button { cursor: pointer; }

/* --- App Shell --- */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 80px;
}

/* --- Typography --- */
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }
.text-3xl { font-size: var(--fs-3xl); }
.text-bold { font-weight: 700; }
.text-semi { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-money { color: var(--money); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }

.text-hero {
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.5px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.section-label {
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.tabular-nums {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* --- Screen Container --- */
.screen {
  padding: var(--sp-lg);
  padding-top: calc(var(--sp-lg) + env(safe-area-inset-top, 0px));
  max-width: 500px;
  margin: 0 auto;
  animation: fadeIn 300ms ease;
  overflow-x: hidden;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg);
  padding-top: calc(var(--sp-xl) + env(safe-area-inset-top, 0px));
  max-width: 500px;
  margin: 0 auto;
}


.screen-title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--min-tap);
  height: var(--min-tap);
  border-radius: var(--radius-pill);
  transition: transform 100ms ease;
}
.back-btn:active { transform: scale(0.97); }

/* --- Frosted Glass Header --- */
.frosted-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

/* --- 3D Cards (critical visual upgrade) --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.card-accent {
  border-left: 4px solid var(--accent);
}

.card-money {
  border-left: 4px solid var(--money);
}

.card-warning {
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
}

.card-danger {
  border-left: 4px solid var(--danger);
  background: var(--danger-bg);
}

.card-title {
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-xs);
}

.card-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.card-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-xs);
}

@media (prefers-color-scheme: dark) {
  .card-warning {
    background: rgba(180, 83, 9, 0.15);
  }
  .card-danger {
    background: rgba(185, 28, 28, 0.15);
  }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  min-height: var(--min-tap);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--fs-base);
  transition: transform 100ms ease, background 150ms ease, box-shadow 150ms ease;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-primary:active {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--card-border);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-success {
  background: var(--money);
  color: #FFFFFF;
}

.btn-sm {
  min-height: 36px;
  padding: var(--sp-sm) var(--sp-lg);
  font-size: var(--fs-sm);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--min-tap);
  height: var(--min-tap);
  padding: 0;
  border-radius: var(--radius-pill);
}

.btn-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn-loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--sp-sm);
}

/* --- FAB (Floating Action Button) --- */
.fab {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(220, 115, 39, 0.4);
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 50;
}
.fab:active {
  transform: scale(0.9);
}

.fab-pulse {
  animation: fabPulse 2s ease-in-out infinite;
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(220,115,39,0.4); }
  50% { box-shadow: 0 4px 24px rgba(220,115,39,0.7), 0 0 40px rgba(220,115,39,0.3); }
}

/* --- Inputs --- */
.input-group {
  margin-bottom: var(--sp-lg);
}

.input-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-sm);
}

.input {
  width: 100%;
  min-height: var(--min-tap);
  padding: var(--sp-md) var(--sp-lg);
  background: var(--color-surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--color-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(220,115,39,0.15);
}
.input::placeholder {
  color: var(--text-muted);
}

.input-lg {
  font-size: var(--fs-xl);
  font-weight: 700;
  text-align: center;
  padding: var(--sp-lg);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

textarea.input {
  min-height: 80px;
  resize: vertical;
}

/* --- Pills / Badges --- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-tap);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--color-surface);
  color: var(--color-text);
  transition: transform 100ms ease, background 150ms ease;
  cursor: pointer;
}
.pill:active { transform: scale(0.97); }

.pill-active {
  background: var(--accent);
  color: #FFFFFF;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.badge-green { background: var(--money-bg); color: var(--money); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--color-surface); color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
  .badge-green { background: rgba(26, 122, 74, 0.2); }
  .badge-orange { background: rgba(180, 83, 9, 0.2); }
  .badge-red { background: rgba(185, 28, 28, 0.2); }
}

/* --- Status Chips --- */
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  animation: statusAppear 250ms ease both;
}

.status-green { background: var(--money-bg); color: var(--money); }
.status-orange { background: var(--warning-bg); color: var(--warning); }
.status-red { background: var(--danger-bg); color: var(--danger); }
.status-gray { background: var(--color-surface); color: var(--text-muted); }

@keyframes statusAppear {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-color-scheme: dark) {
  .status-green { background: rgba(26, 122, 74, 0.2); }
  .status-orange { background: rgba(180, 83, 9, 0.2); }
  .status-red { background: rgba(185, 28, 28, 0.2); }
}

/* --- Segmented Control --- */
.segmented {
  display: flex;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.segmented-btn {
  flex: 1;
  min-height: var(--min-tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: transform 100ms ease, background 150ms ease;
}
.segmented-btn:active { transform: scale(0.97); }

.segmented-btn-active {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

/* --- Bottom Navigation (Frosted Glass) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--glass-bg);
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: var(--min-tap);
  gap: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  transition: transform 100ms ease, color 150ms ease;
}
.nav-item:active { transform: scale(0.97); }

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

.nav-icon {
  width: 24px;
  height: 24px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
  z-index: 1000;
  white-space: nowrap;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: slideUp 250ms ease;
}

.toast-success {
  background: var(--money);
  color: #FFFFFF;
}

.toast-info {
  background: var(--accent);
  color: #FFFFFF;
}

.toast-warning {
  background: var(--warning);
  color: #FFFFFF;
}

.toast-error {
  background: var(--danger);
  color: #FFFFFF;
}

/* --- Bottom Sheet --- */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  transition: background 300ms ease;
}

.bottom-sheet-visible {
  background: rgba(0,0,0,0.4);
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-2xl) + env(safe-area-inset-bottom, 0px));
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 400ms cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}

.bottom-sheet-visible .bottom-sheet {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.3;
  margin: 0 auto var(--sp-lg);
}

/* --- Dialog --- */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: var(--sp-lg);
  animation: fadeIn 200ms ease;
}

.dialog-content {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: var(--sp-2xl);
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 250ms ease;
}

.dialog-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--sp-md);
}

.dialog-message {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-xl);
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  gap: var(--sp-sm);
  justify-content: flex-end;
}

.dialog-cancel {
  min-height: var(--min-tap);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--radius-pill);
  font-weight: 600;
  color: var(--text-muted);
  transition: transform 100ms ease;
}
.dialog-cancel:active { transform: scale(0.97); }

.dialog-cards {
  justify-content: center;
  margin-bottom: var(--sp-xl);
}

/* --- Identity Screen --- */
.identity-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--sp-2xl);
  animation: fadeIn 600ms ease;
}

.identity-header {
  text-align: center;
  margin-bottom: var(--sp-4xl);
}

.identity-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-sm);
}

.identity-subtitle {
  font-size: var(--fs-base);
  color: var(--text-muted);
}

.identity-cards {
  display: flex;
  gap: var(--sp-lg);
}

.identity-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-2xl) var(--sp-3xl);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: transform 100ms ease, box-shadow 200ms ease;
  min-width: 140px;
  cursor: pointer;
}
.identity-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

.identity-card-selected {
  box-shadow: 0 0 0 3px rgba(220,115,39,0.3), var(--shadow);
  border-color: var(--accent);
}

.identity-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-pill);
  background: var(--money);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xl);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(26, 122, 74, 0.35);
}

.identity-name {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.identity-card-sm {
  padding: var(--sp-lg) var(--sp-xl);
  min-width: 100px;
}

.identity-avatar-sm {
  width: 48px;
  height: 48px;
  font-size: var(--fs-base);
}

/* --- User Badge --- */
.user-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--money);
  box-shadow: 0 2px 10px rgba(26, 122, 74, 0.35);
  transition: transform 100ms ease;
}
.user-badge:active { transform: scale(0.97); }

.user-badge-initials {
  color: #FFFFFF;
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* --- Offline Badge --- */
.offline-badge {
  position: fixed;
  top: 8px;
  right: 8px;
  min-width: 18px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 300ms ease;
}

.offline-badge.visible {
  display: flex;
}

/* --- Loading Screen --- */
.loading-screen {
  background: linear-gradient(180deg, #0F5234 0%, #1A7A4A 50%, #0F5234 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sp-2xl) + env(safe-area-inset-top, 0px)) var(--sp-2xl) calc(var(--sp-2xl) + env(safe-area-inset-bottom, 0px));
  text-align: center;
  animation: fadeIn 600ms ease;
  position: relative;
  overflow: hidden;
}

/* Subtle radial light behind title */
.loading-screen::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 60%);
  transform: translate(-50%, -55%);
  pointer-events: none;
}

/* Subtle grain overlay */
.loading-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  opacity: 0.6;
}

.loading-signature {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: var(--sp-lg);
  position: relative;
  z-index: 1;
  font-style: italic;
}

.loading-title {
  color: #FFFFFF;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: var(--sp-sm);
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
}

.loading-divider {
  width: 40px;
  height: 2px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 2px;
  margin: var(--sp-lg) 0 var(--sp-xl);
  position: relative;
  z-index: 1;
}

.loading-value {
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.65;
  max-width: 320px;
  transition: opacity 400ms ease;
  position: relative;
  z-index: 1;
  letter-spacing: 0.01em;
}

.loading-verse-ref {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: var(--sp-sm);
  position: relative;
  z-index: 1;
  font-style: normal;
}

.value-fade-out {
  opacity: 0;
}

.value-fade-in {
  opacity: 1;
}

/* --- Metric Cards (budget) --- */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.metric-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  padding: var(--sp-sm) var(--sp-xs);
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: var(--sp-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value {
  font-size: var(--fs-base);
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* When hero text sits inside a metric-card, shrink it so it never overflows */
.metric-card .text-hero {
  font-size: var(--fs-lg);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value-lg {
  font-size: var(--fs-xl);
  color: var(--accent);
}

/* --- Quick Actions --- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  min-height: var(--min-tap);
  padding: var(--sp-md) var(--sp-sm);
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--card-border);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-text);
  transition: transform 100ms ease;
}
.quick-action:active { transform: scale(0.97); }

.quick-action-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* --- Bill Card --- */
.bill-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-sm);
  transition: transform 100ms ease, box-shadow 100ms ease;
  min-height: var(--min-tap);
}
.bill-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.bill-card-paid {
  opacity: 0.6;
}

.bill-card-due {
  animation: pulse 2s ease-in-out infinite;
}

.bill-paid-text {
  text-decoration: line-through;
}

.bill-info {
  flex: 1;
}

.bill-name {
  font-weight: 600;
  font-size: var(--fs-base);
}

.bill-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.bill-amount {
  font-weight: 700;
  font-size: var(--fs-lg);
  margin-right: var(--sp-md);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.bill-check {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.bill-check-paid {
  background: var(--money);
  border-color: var(--money);
  color: #FFFFFF;
}

/* --- Task Card --- */
.task-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-sm);
  transition: transform 100ms ease, box-shadow 100ms ease;
  cursor: pointer;
  border-left: 4px solid transparent;
}
.task-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.task-card-today {
  border-left-color: var(--accent);
}

.task-card-done {
  opacity: 0.6;
}

.task-card-done .task-name {
  text-decoration: line-through;
}

.task-status-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  margin-top: 4px;
  flex-shrink: 0;
}

.dot-not-started { background: var(--text-muted); }
.dot-in-progress { background: var(--warning); }
.dot-done { background: var(--money); }

.task-info { flex: 1; }

.task-name {
  font-weight: 600;
  font-size: var(--fs-base);
  margin-bottom: 2px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* --- Category Grid (spending) --- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-sm);
}

.category-pill {
  min-height: var(--min-tap);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  transition: transform 100ms ease, background 150ms ease;
  cursor: pointer;
}
.category-pill:active { transform: scale(0.97); }

.category-pill-active {
  background: var(--accent);
  color: #FFFFFF;
}

/* --- Budget Overview Category Card --- */
.budget-cat-card {
  padding: var(--sp-lg);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-sm);
  border-left: 4px solid var(--text-muted);
}

.budget-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-sm);
}

.budget-cat-name {
  font-weight: 600;
}

.budget-cat-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.budget-cat-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--color-surface);
  margin-top: var(--sp-sm);
  overflow: hidden;
}

.budget-cat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 300ms ease;
}

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-xl);
  margin-bottom: var(--sp-md);
}

.section-title {
  font-size: var(--fs-base);
  font-weight: 700;
}

.section-link {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  min-height: var(--min-tap);
  display: flex;
  align-items: center;
}

/* --- Banner --- */
.banner {
  padding: var(--sp-lg);
  border-radius: var(--radius);
  margin-bottom: var(--sp-md);
}

.banner-green {
  background: var(--money-bg);
  color: var(--money);
}

.banner-orange {
  background: var(--warning-bg);
  color: var(--warning);
}

.banner-red {
  background: var(--danger-bg);
  color: var(--danger);
}

.banner-neutral {
  background: var(--color-surface);
  color: var(--text-muted);
}

@media (prefers-color-scheme: dark) {
  .banner-green { background: rgba(26, 122, 74, 0.15); }
  .banner-orange { background: rgba(180, 83, 9, 0.15); }
  .banner-red { background: rgba(185, 28, 28, 0.15); }
}

.banner-text {
  font-weight: 600;
  font-size: var(--fs-base);
}

/* --- Money Green Utilities --- */
.bg-money {
  background: var(--money-bg);
}

@media (prefers-color-scheme: dark) {
  .bg-money {
    background: rgba(26, 122, 74, 0.15);
  }
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--sp-4xl) var(--sp-lg);
  color: var(--text-muted);
  animation: fadeIn 300ms ease;
}

.empty-state-icon {
  font-size: var(--fs-3xl);
  margin-bottom: var(--sp-md);
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--fs-base);
  margin-bottom: var(--sp-lg);
  line-height: 1.6;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--card-border);
  margin: var(--sp-lg) 0;
}

/* --- Progress Bar --- */
.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--color-surface);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 500ms ease;
}

.progress-bar-money .progress-bar-fill {
  background: var(--money);
}

.progress-bar-danger .progress-bar-fill {
  background: var(--danger);
}

/* --- Animations --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

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

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

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

@keyframes pulse {
  0%, 100% {
    border-color: var(--card-border);
  }
  50% {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.2);
  }
}

.fade-in {
  animation: fadeIn 300ms ease;
}

.slide-up {
  animation: slideUp 250ms ease;
}

.count-up {
  animation: countUp 400ms ease;
}

/* Stagger animation classes */
.stagger-1 { animation: staggerIn 300ms ease both; animation-delay: 50ms; }
.stagger-2 { animation: staggerIn 300ms ease both; animation-delay: 100ms; }
.stagger-3 { animation: staggerIn 300ms ease both; animation-delay: 150ms; }
.stagger-4 { animation: staggerIn 300ms ease both; animation-delay: 200ms; }
.stagger-5 { animation: staggerIn 300ms ease both; animation-delay: 250ms; }
.stagger-6 { animation: staggerIn 300ms ease both; animation-delay: 300ms; }

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, rgba(0,0,0,0.05) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

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

.skeleton-text {
  height: 16px;
  margin-bottom: var(--sp-sm);
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--sp-md);
}

.skeleton-card {
  height: 80px;
  margin-bottom: var(--sp-md);
}

/* --- Checkbox --- */
.checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  min-height: var(--min-tap);
  cursor: pointer;
  transition: transform 100ms ease;
}
.checkbox:active { transform: scale(0.97); }

.checkbox-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 150ms ease;
}

.checkbox-checked .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label {
  font-size: var(--fs-base);
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.3;
}

/* --- Safe Area --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(72px + env(safe-area-inset-bottom));
  }
  #app {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* --- App Lock Screen --- */
#lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(180deg, #0F5234 0%, #1A7A4A 50%, #0F5234 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
  animation: fadeIn 250ms ease;
}
#lock-overlay.lock-unlock {
  opacity: 0;
  transition: opacity 220ms ease;
}
.lock-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  color: #fff;
}
.lock-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.lock-sub {
  font-size: 13px;
  opacity: 0.75;
  margin-bottom: 28px;
}
.lock-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 12px;
}
.lock-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 120ms ease, transform 120ms ease;
}
.lock-dot-filled {
  background: #fff;
  transform: scale(1.1);
}
.lock-error {
  color: #FDA4AF;
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 10px;
}
.lock-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 12px;
}
.lock-key {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  height: 64px;
  transition: transform 80ms ease, background 120ms ease;
}
.lock-key:active {
  transform: scale(0.93);
  background: rgba(255,255,255,0.18);
}
.lock-key-ghost {
  background: transparent;
  font-size: 18px;
}
.lock-key-ghost:disabled {
  visibility: hidden;
}
.lock-shake {
  animation: lockShake 400ms ease;
}
@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* --- Theme Swatches --- */
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: transparent;
  border: 2px solid transparent;
  transition: transform 120ms ease, border-color 120ms ease;
  min-width: 64px;
}
.theme-swatch:active { transform: scale(0.94); }
.theme-swatch-active {
  border-color: var(--accent);
  background: rgba(255,255,255,0.04);
}
.theme-swatch-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.theme-swatch-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

/* --- Pull To Refresh --- */
.ptr-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
}
.ptr-spinner.ptr-spinning {
  animation: ptrSpin 0.8s linear infinite;
}
@keyframes ptrSpin {
  to { transform: rotate(360deg); }
}

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--sp-xs); }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.gap-lg { gap: var(--sp-lg); }
.w-full { width: 100%; }
.mt-xs { margin-top: var(--sp-xs); }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); }
.mt-xl { margin-top: var(--sp-xl); }
.mb-xs { margin-bottom: var(--sp-xs); }
.mb-sm { margin-bottom: var(--sp-sm); }
.mb-md { margin-bottom: var(--sp-md); }
.mb-lg { margin-bottom: var(--sp-lg); }
.p-lg { padding: var(--sp-lg); }
.hidden { display: none !important; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
