/* ── Bottom Tab Bar ── */
#tab-bar {
  display: flex;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 50;
  flex-shrink: 0;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .3px;
  transition: color var(--dur) var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tab-item svg { width: 22px; height: 22px; transition: transform var(--dur) var(--ease); }
.tab-item.active { color: var(--primary); }
.tab-item.active svg { transform: scale(1.1); }
.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}
.tab-item:active svg { transform: scale(.92); }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  padding-top: calc(16px + var(--safe-top));
  min-height: var(--header-h);
  flex-shrink: 0;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
}
.header-actions { display: flex; gap: 8px; }

/* ── Icon Button ── */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── Primary Button ── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  width: 100%;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  box-shadow: 0 4px 16px rgba(21,128,61,.3);
  -webkit-tap-highlight-color: transparent;
  font-family: 'Comme', sans-serif;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(.98); box-shadow: none; }
.btn-primary:disabled { opacity: .5; pointer-events: none; }

/* ── Secondary Button ── */
.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  width: 100%;
  border: 1.5px solid var(--border);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
  font-family: 'Comme', sans-serif;
}
.btn-secondary:active { background: var(--surface-2); transform: scale(.98); }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 10px; }

/* ── Section ── */
.section { padding: 0 20px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* ── Transit Card ── */
.transit-card {
  border-radius: 20px;
  padding: 22px;
  position: relative;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.transit-card:active { transform: scale(.97); }
.transit-card.green  { background: linear-gradient(135deg, #15803d 0%, #22c55e 100%); color: #fff; }
.transit-card.dark   { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); color: #fff; }
.transit-card.earth  { background: linear-gradient(135deg, #92400e 0%, #d97706 100%); color: #fff; }
.transit-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.transit-card::after {
  content: '';
  position: absolute;
  bottom: -50px; right: 30px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.tc-chip {
  width: 32px; height: 24px;
  background: rgba(255,255,255,.3);
  border-radius: 5px;
  position: relative;
  z-index: 1;
}
.tc-top { display: flex; align-items: center; justify-content: space-between; }
.tc-brand { font-size: 13px; font-weight: 700; letter-spacing: 1px; opacity: .85; z-index: 1; }
.tc-balance-label { font-size: 11px; opacity: .75; font-weight: 500; z-index: 1; }
.tc-balance { font-size: 26px; font-weight: 800; letter-spacing: -1px; z-index: 1; }
.tc-bottom { display: flex; align-items: flex-end; justify-content: space-between; z-index: 1; }
.tc-name { font-size: 13px; font-weight: 600; opacity: .9; z-index: 1; }
.tc-status {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  background: rgba(255,255,255,.2);
  padding: 3px 8px; border-radius: 10px;
  z-index: 1;
}

/* ── Metric Pill ── */
.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric-pill {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.metric-pill .label { font-size: 11px; color: var(--text-3); font-weight: 500; margin-bottom: 4px; }
.metric-pill .value { font-size: 18px; font-weight: 700; color: var(--text); }
.metric-pill .sub { font-size: 11px; color: var(--primary); font-weight: 500; margin-top: 2px; }

/* ── Trip Item ── */
.trip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.trip-item:last-child { border-bottom: none; }
.trip-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary-subtle);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}
.trip-icon svg { width: 18px; height: 18px; }
.trip-info { flex: 1; min-width: 0; }
.trip-route { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.trip-amount { font-size: 15px; font-weight: 700; color: var(--danger); }
.trip-amount.credit { color: var(--success); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  animation: toastIn .3s var(--ease) both, toastOut .3s var(--ease) .8s both;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.toast.success { background: var(--primary); color: #fff; }
.toast.error   { background: var(--danger);  color: #fff; }
.toast.warn    { background: var(--warn);    color: #fff; }
@keyframes toastIn  { from { opacity:0; transform:translateY(12px) scale(.92); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(-8px); } }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: flex-end;
  animation: fadeIn var(--dur) var(--ease) both;
}
.modal-backdrop.closing { animation: fadeOut var(--dur) var(--ease) both; }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes fadeOut { from { opacity:1; } to { opacity:0; } }
.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  width: 100%;
  animation: sheetUp var(--dur-lg) var(--ease) both;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-backdrop.closing .modal-sheet { animation: sheetDown var(--dur) var(--ease) both; }
@keyframes sheetUp   { from { transform:translateY(100%); } to { transform:translateY(0); } }
@keyframes sheetDown { from { transform:translateY(0); } to { transform:translateY(100%); } }
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ── Input ── */
.input-group { margin-bottom: 14px; }
.input-group label { font-size: 13px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 6px; }
.input-field {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  font-family: 'Comme', sans-serif;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  outline: none;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,128,61,.15); }
.input-field::placeholder { color: var(--text-3); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 10px;
  letter-spacing: .3px;
}
.badge-green  { background: var(--primary-subtle); color: var(--primary-dark); }
.badge-warn   { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .badge-warn   { background: #422006; color: #fcd34d; }
[data-theme="dark"] .badge-danger { background: #3f0e0e; color: #fca5a5; }

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

/* ── Empty State ── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}
.empty-icon { font-size: 48px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text); }
.empty-sub { font-size: 14px; color: var(--text-3); }
