/* PayDay App - Design System */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-deeper: #1e40af;
  --primary-light: #dbeafe;
  --primary-glow: rgba(37, 99, 235, 0.15);
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #10b981;
  --success-light: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ── */
.page-header {
  background: linear-gradient(135deg, #1e40af, #2563eb, #3b82f6);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.page-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}
.page-header h1 {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.01em;
}
.page-header .back-btn,
.page-header .action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.page-header .back-btn:active,
.page-header .action-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Container ── */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
.container.wide {
  max-width: 900px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.card.clickable {
  cursor: pointer;
}
.card.clickable:active {
  transform: scale(0.98);
}

/* ── Nav cards (dashboard) ── */
.nav-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.nav-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.nav-card:active {
  transform: scale(0.98);
}
.nav-card:active::before,
.nav-card:hover::before {
  opacity: 1;
}
.nav-card .icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.nav-card .label {
  font-size: 15px;
  font-weight: 600;
  position: relative;
  z-index: 1;
  letter-spacing: -0.01em;
}
.nav-card .sublabel {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  position: relative;
  z-index: 1;
}
.nav-card .arrow {
  margin-left: auto;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  transition: transform var(--transition);
}
.nav-card:hover .arrow {
  transform: translateX(2px);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: -0.01em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input[readonly] {
  background: var(--bg);
  color: var(--text-secondary);
  border-color: transparent;
}

.form-section {
  margin-bottom: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin: 0;
  padding: 0;
  border: none;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-strong);
}
.btn-outline:active { background: var(--bg); }
.btn-block { width: 100%; }

/* ── Record items ── */
.record-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.record-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: var(--border);
}
.record-item:last-child::after { display: none; }
.record-item:active { background: var(--bg); }
.record-item .info { flex: 1; }
.record-item .name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.record-item .date {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.record-item .arrow {
  color: var(--text-muted);
  transition: transform var(--transition);
}
.record-item:active .arrow { transform: translateX(2px); }

/* ── Detail rows ── */
.detail-row {
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}
.detail-row::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.detail-row:last-child::after { display: none; }
.detail-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}
.detail-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ── Leaderboard ── */
.leaderboard-select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  margin-bottom: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.leaderboard-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
  padding: 6px 0;
}
.bar-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-secondary);
}
.bar-rank.gold { background: #fef3c7; color: #d97706; }
.bar-rank.silver { background: #f1f5f9; color: #64748b; }
.bar-rank.bronze { background: #fef2ee; color: #c2410c; }
.bar-name {
  width: 100px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  letter-spacing: -0.01em;
}
.bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 2px;
}
.bar-value {
  min-width: 50px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  text-align: right;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 14px 28px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  letter-spacing: -0.01em;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── Impersonation Banner ── */
.impersonation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}
.impersonation-banner .imp-icon {
  flex-shrink: 0;
  opacity: 0.9;
}
.impersonation-banner .imp-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.impersonation-banner .imp-stop {
  flex-shrink: 0;
  background: rgba(255,255,255,0.25);
  border: none;
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 100px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.impersonation-banner .imp-stop:active {
  background: rgba(255,255,255,0.4);
}
body.impersonating .page-header {
  margin-top: 42px;
}
body.impersonating .logo-bar {
  margin-top: 42px;
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  justify-content: center;
  padding: 48px;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 50;
  justify-content: center;
  align-items: flex-end;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--surface);
  border-radius: 20px 20px 20px 20px;
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Desktop ── */
@media (min-width: 768px) {
  .container { padding: 28px; }
  .container.wide { max-width: 1000px; }
  .page-header { padding: 18px 28px; }
  .page-header h1 { font-size: 19px; }
  .bar-name { width: 160px; font-size: 14px; }
  .nav-card { padding: 20px 24px; }
  .nav-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
  }
  .modal-overlay {
    align-items: center;
  }
  .modal {
    border-radius: 20px;
  }
}
