@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #34d399;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --danger: #ef4444;
  --danger-light: #fca5a5;
  --success: #22c55e;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-light: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 80px;
}

/* Page transitions */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

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

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

@keyframes slideDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  padding: 16px 20px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

.nav-item svg { width: 22px; height: 22px; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.card:hover { border-color: var(--primary); }

.card-glow {
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.05));
  border-color: rgba(16,185,129,0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Inter', sans-serif;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5); }

.btn-secondary {
  background: var(--bg-card-light);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-sm { padding: 8px 16px; font-size: 0.8rem; border-radius: 8px; }
.btn-full { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 12px; }

/* Inputs */
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.input::placeholder { color: var(--text-muted); }

/* Person avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.2rem; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--bg-card-light);
  border-radius: 4px;
  margin: 0 auto 16px;
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--bg-card-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 90%;
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-cash { background: rgba(34,197,94,0.15); color: #4ade80; }
.tag-card { background: rgba(59,130,246,0.15); color: #60a5fa; }
.tag-transfer { background: rgba(168,85,247,0.15); color: #c084fc; }

/* Scan overlay */
.scan-frame {
  width: 260px;
  height: 340px;
  border: 2px solid var(--primary);
  border-radius: 16px;
  position: relative;
  margin: 0 auto;
}

.scan-frame::before, .scan-frame::after,
.scan-frame .corner-bl, .scan-frame .corner-br {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid var(--accent);
}

.scan-frame::before { top: -3px; left: -3px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-frame::after { top: -3px; right: -3px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-frame .corner-bl { bottom: -3px; left: -3px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-frame .corner-br { bottom: -3px; right: -3px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }

.scan-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  animation: scanAnim 2s ease-in-out infinite;
}

@keyframes scanAnim {
  0%, 100% { top: 10px; }
  50% { top: calc(100% - 10px); }
}

/* Split type tabs */
.split-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--border);
}

.split-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.split-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

/* Status badges */
.status-paid { color: var(--success); }
.status-partial { color: var(--accent); }
.status-unpaid { color: var(--danger); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

/* Install banner */
.install-banner {
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(245,158,11,0.1));
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.install-banner:hover { border-color: var(--primary); }

/* Currency selector */
.currency-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.currency-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Receipt item row animation */
.item-row {
  animation: fadeIn 0.3s ease;
  animation-fill-mode: both;
}

.item-row:nth-child(1) { animation-delay: 0.05s; }
.item-row:nth-child(2) { animation-delay: 0.1s; }
.item-row:nth-child(3) { animation-delay: 0.15s; }
.item-row:nth-child(4) { animation-delay: 0.2s; }
.item-row:nth-child(5) { animation-delay: 0.25s; }

/* Payment method cards */
.method-card {
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  text-align: center;
}

.method-card.selected {
  border-color: var(--primary);
  background: rgba(16,185,129,0.1);
}

.method-card svg { width: 28px; height: 28px; margin: 0 auto 6px; }

/* Number pad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}

.numpad button {
  padding: 16px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.numpad button:active {
  background: var(--primary);
  transform: scale(0.95);
}

/* Responsive adjustments */
@media (min-width: 481px) {
  .app-container {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* Toggle switch */
.toggle {
  width: 44px;
  height: 24px;
  background: var(--bg-card-light);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
}

.toggle.active { background: var(--primary); }

.toggle::after {
  content: '';
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.3s;
}

.toggle.active::after { left: 22px; }

/* Step indicator */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-card-light);
  transition: all 0.3s;
  flex-shrink: 0;
}

.step-dot.active { background: var(--primary); width: 24px; border-radius: 4px; }
.step-dot.done { background: var(--primary); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--bg-card-light);
  transition: all 0.3s;
}

.step-line.done { background: var(--primary); }

/* Checkbox */
.checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.checkbox.checked svg { display: block; }
.checkbox svg { display: none; width: 14px; height: 14px; color: white; }

/* Assignment pills */
.assign-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  background: rgba(16,185,129,0.15);
  border: 1px solid rgba(16,185,129,0.3);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary-light);
  cursor: pointer;
}

.assign-pill:hover { background: rgba(16,185,129,0.25); }