/* CollegePay design tokens and shared components.
   Five token families (colour roles, 4px spacing, type scale, radius, two shadows) — no one-off values in app CSS. */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --font: 'Manrope', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;

  /* Colour roles */
  --bg: #F3F8F5;
  --surface: #FFFFFF;
  --surface-2: #F1F8F4;
  --surface-3: #E4F3EB;
  --ink: #0D1F17;
  --ink-2: #33463E;
  --muted: #64766E;
  --line: rgba(13, 31, 23, 0.09);
  --line-strong: rgba(13, 31, 23, 0.16);

  /* Brand greens: sidebar/hero (900–700), action (700), mint accents (400–50) */
  --brand-950: #04241A;
  --brand-900: #062E22;
  --brand-800: #0A3D2D;
  --brand-700: #0E5A41;
  --brand-600: #127552;
  --brand-500: #179563;
  --brand-400: #2EC27E;
  --brand-300: #7ADFAE;
  --brand-200: #BFF0D7;
  --brand-100: #DFF7EA;
  --brand-50: #F0FBF5;
  --primary: var(--brand-700);
  --primary-hover: var(--brand-800);
  --on-primary: #FFFFFF;
  --accent: var(--brand-400);

  /* Status colours (text on tinted background, all ≥ 4.5:1) */
  --success: #0F7A52; --success-bg: #DCF5E8;
  --warn: #A35408;    --warn-bg: #FFF0D4;
  --danger: #B8322E;  --danger-bg: #FDE7E6;
  --info: #1D58C4;    --info-bg: #E2ECFF;
  --purple: #6236C9;  --purple-bg: #EDE6FF;
  --neutral: #4E5D57; --neutral-bg: #ECF0EE;

  /* Spacing on a 4px grid */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* Type scale (1.25 ratio around 16) */
  --t-xs: 11px; --t-sm: 13px; --t-md: 14px; --t-base: 16px; --t-lg: 20px; --t-xl: 25px; --t-2xl: 32px; --t-3xl: 40px;

  /* Radius scale: chips/badges sm, inputs/buttons md, cards lg/xl, sheets 2xl, pills full */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-2xl: 28px; --r-full: 9999px;

  /* Two shadows: resting and floating */
  --shadow-1: 0 1px 2px rgba(6, 46, 34, 0.06), 0 2px 6px -2px rgba(6, 46, 34, 0.06);
  --shadow-2: 0 18px 40px -12px rgba(6, 46, 34, 0.28), 0 6px 14px -6px rgba(6, 46, 34, 0.14);

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --fast: 150ms;
  --med: 250ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--t-base); line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'ss01';
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; font-weight: 800; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { flex: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-400) 70%, transparent); outline-offset: 2px; border-radius: var(--r-sm); }

/* Buttons */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--h); padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--r-md); font-weight: 700; font-size: var(--t-md); line-height: 1; white-space: nowrap;
  text-decoration: none; transition: background var(--fast) var(--ease-out), border-color var(--fast), color var(--fast), transform 120ms var(--spring), box-shadow var(--fast);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-mint { background: var(--brand-100); color: var(--brand-800); }
.btn-mint:hover:not(:disabled) { background: var(--brand-200); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-outline { background: transparent; color: var(--brand-700); border-color: var(--brand-600); }
.btn-outline:hover:not(:disabled) { background: var(--brand-50); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn-sm { --h: 32px; padding: 0 var(--s3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn-lg { --h: 52px; padding: 0 var(--s6); font-size: var(--t-base); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn .spinner { width: 16px; height: 16px; }

/* Chips (filters) and pills (status) */
.chip {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 36px; padding: 0 var(--s4); border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: var(--t-sm); white-space: nowrap;
  transition: background var(--fast), color var(--fast), border-color var(--fast), transform 120ms var(--spring);
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.chip .count { font-size: var(--t-xs); opacity: 0.75; }

.pill {
  display: inline-flex; align-items: center; gap: var(--s1); height: 24px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1;
}
.pill .ic { width: 13px; height: 13px; }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral); }
.pill-mint { background: var(--brand-100); color: var(--brand-700); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-1); }

/* Form fields: 16px text so iOS never zooms */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  font-size: 16px; transition: border-color var(--fast), box-shadow var(--fast);
}
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364766E' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-400) 22%, transparent); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 44px; }

/* Avatars: initials on a soft hue */
.avatar {
  --hue: 150; display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--r-full);
  background: hsl(var(--hue) 55% 90%); color: hsl(var(--hue) 55% 26%); font-weight: 800; font-size: 13px; letter-spacing: 0.02em;
}
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-xl { width: 80px; height: 80px; font-size: 26px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* Switch (applies immediately) */
.switch { position: relative; display: inline-flex; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--line-strong); transition: background var(--med) var(--ease-out); }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--med) var(--spring); }
.switch input:checked + span { background: var(--brand-500); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand-400) 70%, transparent); outline-offset: 2px; }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); }
.seg button { min-height: 36px; padding: 0 var(--s4); border: 0; border-radius: var(--r-full); background: transparent; font-weight: 700; font-size: var(--t-sm); color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand-800); color: #fff; box-shadow: var(--shadow-1); }

/* Skeletons, spinner, empty state */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--r-md); }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: grid; justify-items: center; gap: var(--s2); padding: var(--s10) var(--s4); text-align: center; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: var(--brand-400); }
.empty strong { color: var(--ink); font-size: var(--t-base); }

/* Toasts */
.toasts { position: fixed; z-index: 1000; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: var(--s2); width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s3); padding: 12px 16px; border-radius: var(--r-lg); background: var(--brand-950); color: #fff;
  box-shadow: var(--shadow-2); font-size: var(--t-md); font-weight: 600; animation: toast-in 260ms var(--spring); pointer-events: auto;
}
.toast.is-error { background: #3B0D0C; }
.toast .ic { color: var(--brand-300); }
.toast.is-error .ic { color: #FF9A94; }
.toast.leaving { animation: toast-out 180ms var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Sheets: bottom sheet on phones, centred dialog (or side drawer) on larger screens. One at a time. */
.scrim { position: fixed; inset: 0; z-index: 900; background: rgba(4, 36, 26, 0.45); backdrop-filter: blur(2px); animation: fade-in var(--med) var(--ease-out); }
.scrim.leaving { animation: fade-out 180ms var(--ease-out) forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet {
  position: fixed; z-index: 901; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0; box-shadow: var(--shadow-2);
  animation: sheet-up 320ms var(--ease-out); padding-bottom: env(safe-area-inset-bottom);
}
.sheet.leaving { animation: sheet-down 200ms var(--ease-out) forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 5px; border-radius: var(--r-full); background: var(--line-strong); margin: 10px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5) var(--s3); flex: none; }
.sheet-head h2 { flex: 1; font-size: var(--t-lg); }
.sheet-body { padding: var(--s2) var(--s5) var(--s5); overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: var(--s3); padding: var(--s3) var(--s5) var(--s5); border-top: 1px solid var(--line); flex: none; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, calc(100vw - 48px)); max-height: min(86vh, 820px); border-radius: var(--r-xl);
    transform: translate(-50%, -50%); animation: dialog-in 240ms var(--ease-out); padding-bottom: 0; }
  .sheet.leaving { animation: dialog-out 160ms var(--ease-out) forwards; }
  .sheet.is-drawer { left: auto; right: 0; top: 0; bottom: 0; transform: none; width: clamp(320px, 40vw, 560px); max-height: none; border-radius: var(--r-xl) 0 0 var(--r-xl); animation: drawer-in 280ms var(--ease-out); }
  .sheet.is-drawer.leaving { animation: drawer-out 180ms var(--ease-out) forwards; }
  .sheet.is-wide { width: min(760px, calc(100vw - 48px)); }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: var(--s5); }
}
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translate(-50%, -49%) scale(0.98); } }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }

/* Success tick (circle draws, then tick) */
.tick { width: 72px; height: 72px; }
.tick circle { stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw 420ms var(--ease-out) forwards; }
.tick path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 260ms 300ms var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* Icon tile (merchant/category glyph on a tint of its own colour) */
.icon-tile { display: inline-grid; place-items: center; flex: none; border-radius: var(--r-md); background: color-mix(in srgb, var(--tile) 14%, #fff); color: var(--tile); }
