/* =============================================
   CARDVALUE — DARK FUTURISTIC PURPLE THEME
   ============================================= */

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

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

:root {
  /* Primary purple palette — Fintech/Crypto inspired */
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-dark: #7c3aed;
  --purple-glow: rgba(139, 92, 246, 0.4);
  --purple-subtle: rgba(139, 92, 246, 0.1);
  /* Surfaces */
  --dark: #0a0a0f;
  --surface: #13111a;
  --surface-light: #1a1726;
  --surface-lighter: #221e2e;
  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  /* Text — WCAG AA compliant on dark backgrounds */
  --text: #f0eef5;           /* contrast 14.8:1 on --dark */
  --text-muted: #a8a2b8;     /* contrast 5.2:1 on --surface — passes AA */
  --text-dim: #7d7694;        /* contrast 3.5:1 — decorative only */
  --white: #FFFFFF;
  /* Semantic colors */
  --green: #22c55e;
  --green-light: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --blue: #6366f1;
  /* Destructive */
  --destructive: #DC2626;
  --on-destructive: #FFFFFF;
  /* Spacing & shape */
  --radius: 14px;
  --radius-sm: 10px;
  /* Elevation */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 4px 16px rgba(139, 92, 246, 0.15), 0 12px 40px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  /* Glass */
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  /* Focus ring */
  --ring: var(--purple);
  --ring-offset: 2px;
}

/* ---- ACCESSIBILITY: Focus states ---- */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: var(--ring-offset);
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---- ACCESSIBILITY: Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- ACCESSIBILITY: Skip link ---- */
.skip-link {
  position: absolute; top: -100%; left: 16px;
  background: var(--purple); color: var(--white);
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; z-index: 999;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--dark);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* ---- HEADER ---- */
.header {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--white);
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 60;
}
.header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { flex-shrink: 0; }
.logo-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--purple-light); }
.header-tagline { color: var(--text-muted); font-size: 14px; }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1035 50%, #0f0a1a 100%);
  color: var(--white);
  padding: 16px 24px 14px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--purple-glow) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.5;
}
.hero-inner { max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; }
.hero h1 { font-family: var(--font-display); font-size: clamp(20px, 2.5vw, 26px); font-weight: 700; line-height: 1.15; margin-bottom: 4px; letter-spacing: -0.5px; }
.hero h1 em { font-style: normal; color: var(--purple-light); }
.hero p { color: var(--text-muted); font-size: 13px; max-width: 600px; margin-bottom: 10px; }
.personalize-toggle-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.default-profile-label { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; }
.profile-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.btn-personalize {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white); border: none; padding: 12px 24px;
  border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px var(--purple-glow);
  min-height: 44px;
  touch-action: manipulation;
}
.btn-personalize:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--purple-glow);
}

/* ---- PERSONALIZE DRAWER ---- */
.personalize-drawer {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
}
.personalize-drawer.open { max-height: 600px; }
.personalize-drawer-inner { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-header h3 { font-size: 18px; font-weight: 700; color: var(--text); }
.drawer-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; }
.drawer-close:hover { background: var(--surface-lighter); color: var(--text); }
.drawer-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.spending-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.spending-row label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.input-wrap {
  display: flex; align-items: center;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-light);
  transition: border-color 0.2s;
}
.input-wrap:focus-within { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-subtle); }
.input-wrap span {
  padding: 0 10px; color: var(--text-muted); font-size: 15px;
  background: var(--surface); height: 100%; display: flex; align-items: center;
  border-right: 1.5px solid var(--border-light);
}
.input-wrap input {
  border: none; outline: none; padding: 10px 12px; font-size: 15px; width: 100%;
  background: transparent; color: var(--text); font-family: var(--font);
}
.drawer-footer { display: flex; gap: 12px; }
.btn-reset {
  background: none; border: 1.5px solid var(--border-light); padding: 10px 20px;
  border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--text-muted);
  transition: all 0.15s;
}
.btn-reset:hover { border-color: var(--text-muted); color: var(--text); }
.btn-apply {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white); border: none; padding: 10px 24px;
  border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.btn-apply:hover { box-shadow: 0 4px 16px var(--purple-glow); }

/* ---- FILTER BAR ---- */
.filter-bar {
  background: rgba(19, 17, 26, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.filter-bar-inner { max-width: 1100px; margin: 0 auto; padding: 8px 24px; display: flex; flex-direction: column; gap: 8px; }
.filter-row-top { display: flex; align-items: center; gap: 12px; }

/* Search */
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-light); border: 1.5px solid var(--border-light);
  border-radius: 999px; padding: 6px 14px; flex: 1; max-width: 300px;
  transition: border-color 0.2s;
}
.search-wrap:focus-within { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-subtle); }
.search-icon { color: var(--text-dim); flex-shrink: 0; }
.search-wrap input {
  border: none; outline: none; background: transparent; color: var(--text);
  font-size: 13px; font-family: var(--font); width: 100%;
}
.search-wrap input::placeholder { color: var(--text-dim); }

/* Sort */
.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.sort-wrap select {
  background: var(--surface-light); border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 6px 12px; color: var(--text);
  font-size: 13px; font-family: var(--font); cursor: pointer;
  appearance: auto; outline: none;
  transition: border-color 0.2s;
}
.sort-wrap select:focus { border-color: var(--purple); }

.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: var(--glass);
  font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text-muted);
  transition: all 0.2s;
  min-height: 32px;
  touch-action: manipulation;
}
.chip:hover { border-color: var(--purple); color: var(--purple-light); }
.chip.active {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white); border-color: transparent;
  box-shadow: 0 2px 12px var(--purple-glow);
}
.results-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; margin-left: auto; }

/* Filter row bottom */
.filter-row-bottom { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* Valuation toggle */
.val-toggle {
  display: flex; flex-shrink: 0;
  background: var(--surface-light);
  border: 1.5px solid var(--border-light);
  border-radius: 999px; overflow: hidden;
}
.val-toggle-btn {
  padding: 5px 14px; border: none; background: none;
  font-size: 11px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); white-space: nowrap;
  transition: all 0.2s; font-family: var(--font);
}
.val-toggle-btn:hover { color: var(--text-muted); }
.val-toggle-btn.active {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px var(--purple-glow);
}

/* Valuation toggle wrap */
.val-toggle-wrap { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.val-help-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-light);
  background: none; color: var(--text-dim); font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-family: var(--font);
}
.val-help-btn:hover { border-color: var(--purple); color: var(--purple-light); }

/* Valuation help popover */
.val-help-popover {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
.val-help-popover.open { display: flex; }
.val-help-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 460px; width: 100%;
  padding: 24px; box-shadow: var(--shadow-lg);
}
.val-help-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.val-help-header strong { font-size: 16px; color: var(--text); }
.val-help-close {
  background: none; border: none; color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.val-help-close:hover { background: var(--surface-lighter); color: var(--text); }
.val-help-section { margin-bottom: 16px; }
.val-help-section:last-child { margin-bottom: 0; }
.val-help-title {
  font-size: 14px; font-weight: 700; color: var(--purple-light); margin-bottom: 6px;
}
.val-help-content p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }
.val-help-table {
  width: 100%; border-collapse: collapse; margin: 10px 0;
}
.val-help-table td {
  padding: 6px 0; font-size: 13px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.val-help-table td:last-child { text-align: right; font-weight: 600; color: var(--green); }
.val-help-note { font-size: 12px; color: var(--text-dim); font-style: italic; }

/* ---- MAIN / CARD TABLE ---- */
.main { padding: 12px 24px 120px; }
.main-inner { max-width: 1100px; margin: 0 auto; }
.table-wrap { overflow-x: auto; }

/* Loading */
.loading-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 80px; color: var(--text-muted); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-light); border-top-color: var(--purple); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- CARD TABLE ---- */
.card-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
}
.card-table thead th {
  background: var(--surface);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 8px 8px;
  border-bottom: 2px solid var(--border-light);
  text-align: left; white-space: nowrap;
}
.th-rate, .th-earned, .th-fee, .th-net { text-align: right; }
.th-compare { text-align: center; width: 40px; }
.th-rank { width: 36px; text-align: center; }
.th-card { min-width: 160px; }

/* Column header help button */
.col-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--border-light); background: none;
  color: var(--text-dim); font-size: 9px; font-weight: 700;
  cursor: pointer; margin-left: 3px; vertical-align: middle;
  transition: all 0.2s; font-family: var(--font);
}
.col-help:hover { border-color: var(--purple); color: var(--purple-light); }

/* Table rows */
.card-row {
  cursor: pointer; transition: background 0.2s ease, box-shadow 0.2s ease;
}
.card-row:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.card-row:hover {
  background: var(--surface-light);
  box-shadow: inset 3px 0 0 var(--purple);
}
.card-row.selected { background: rgba(99, 102, 241, 0.08); }
.card-row td {
  padding: 10px 8px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: var(--text-muted); vertical-align: middle;
}

/* Rank column */
.td-rank {
  text-align: center; font-weight: 800; font-size: 14px; color: var(--text-dim);
}
.td-rank span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; font-weight: 800;
}
.card-row:nth-child(1) .td-rank span {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(139, 92, 246, 0.1));
  color: var(--purple-light);
  border: 2px solid var(--purple);
  box-shadow: 0 0 12px var(--purple-glow);
}
.card-row:nth-child(2) .td-rank span {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 2px solid var(--border-light);
}
.card-row:nth-child(3) .td-rank span {
  background: rgba(251, 146, 60, 0.1);
  color: #fb923c;
  border: 2px solid rgba(251, 146, 60, 0.3);
}

/* Card identity column */
.card-identity { display: flex; align-items: center; gap: 10px; }
.card-logo-inline {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--surface-lighter); border: 1px solid var(--border);
  overflow: hidden;
}
.card-name { font-size: 13px; font-weight: 700; color: var(--text); display: block; }
.card-issuer { font-size: 12px; color: var(--text-muted); }

/* Value columns */
.td-rate { text-align: right; }
.rate-pct { display: block; font-size: 14px; font-weight: 800; color: var(--green); }
.rate-type { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: 2px; white-space: nowrap; }
.acronym-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid var(--border-light); background: none;
  color: var(--text-dim); font-size: 8px; font-weight: 700;
  cursor: help; vertical-align: middle;
  transition: all 0.2s; position: relative;
}
.acronym-help:hover { border-color: var(--purple); color: var(--purple-light); }
.acronym-help:hover::after {
  content: attr(title);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--surface-lighter); border: 1px solid var(--border-light);
  color: var(--text); font-size: 12px; font-weight: 400;
  padding: 8px 12px; border-radius: 8px; white-space: normal;
  width: 220px; z-index: 100; box-shadow: var(--shadow);
  pointer-events: none; margin-bottom: 6px; line-height: 1.5;
}
.td-earned { text-align: right; font-weight: 600; color: var(--text); }
.td-fee { text-align: right; color: var(--text-muted); }
.no-fee { color: var(--green); font-weight: 600; }
.td-net { text-align: right; font-weight: 700; }
.td-net.positive { color: var(--green); }
.td-net.negative { color: var(--red); }

/* Apply link */
.th-apply { text-align: center; width: 70px; }
.td-apply { text-align: center; }
.apply-link {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white); font-size: 12px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  transition: all 0.2s;
}
.apply-link:hover {
  box-shadow: 0 4px 16px var(--purple-glow);
  transform: translateY(-1px);
}

/* Credits tag in table */
.credits-tag {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--purple-light);
  margin-top: 2px;
  white-space: nowrap;
}

/* Credits list in detail drawer */
.credits-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.credit-item {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.credit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.credit-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.credit-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}
.credit-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.credit-total {
  background: var(--surface-lighter);
  border-color: var(--border-light);
}
.credit-total .credit-label {
  font-weight: 800;
}
.credit-total .credit-value {
  font-size: 16px;
}
.credits-caveat {
  background: rgba(251, 146, 60, 0.08);
  border: 1px solid rgba(251, 146, 60, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: #fbbf24;
  margin-top: 12px;
  line-height: 1.5;
}
.credits-disclaimer {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 10px;
  line-height: 1.5;
}

/* Credit realization: struck-through face value + type badges */
.credit-face {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  margin-right: 4px;
}
.credit-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
}
.credit-type-automatic {
  color: var(--green);
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.25);
}
.credit-type-flexible {
  color: var(--green);
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.2);
}
.credit-type-drip {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.2);
}
.credit-type-portal {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.08);
  border-color: rgba(251, 146, 60, 0.2);
}
.credit-type-coupon {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.2);
}

/* Compare checkbox */
.td-compare { text-align: center; }
.compare-check {
  width: 18px; height: 18px;
  accent-color: var(--purple); cursor: pointer;
}

/* ---- DETAIL DRAWER (right side) ---- */
.detail-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  z-index: 100; backdrop-filter: blur(4px);
}
.detail-overlay.open { display: block; }
.detail-drawer {
  position: fixed; top: 0; right: -520px; width: 100%; max-width: 500px;
  height: 100vh; background: var(--surface); z-index: 101;
  overflow-y: auto; transition: right 0.3s ease; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
}
.detail-drawer.open { right: 0; }
.detail-drawer-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.detail-card-identity { display: flex; align-items: center; gap: 14px; }
.detail-logo {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--surface-lighter); display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0; border: 1px solid var(--border);
  overflow: hidden;
}
.detail-logo img { width: 100%; height: 100%; object-fit: contain; }
.detail-drawer-header h2 { font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--text); }
.detail-issuer { font-size: 13px; color: var(--text-muted); }
.detail-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; line-height: 1; }
.detail-close:hover { background: var(--surface-lighter); color: var(--text); }
.detail-drawer-body { padding: 24px; flex: 1; }

/* Detail sections */
.detail-section { margin-bottom: 28px; }
.detail-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 12px; }
.value-highlight-box {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
  border-radius: var(--radius); padding: 20px; text-align: center;
  border: 1px solid rgba(34, 197, 94, 0.2); margin-bottom: 16px;
}
.value-highlight-box .big-number { font-size: 42px; font-weight: 800; color: var(--green); line-height: 1; }
.value-highlight-box .big-label { font-size: 13px; color: var(--green); margin-top: 4px; opacity: 0.8; }
.value-highlight-box .big-sub { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* Category breakdown table */
.cat-table { width: 100%; border-collapse: collapse; }
.cat-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); padding: 6px 0; border-bottom: 1px solid var(--border); text-align: left; }
.cat-table th:last-child, .cat-table td:last-child { text-align: right; }
.cat-table td { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-muted); }
.cat-table tr:last-child td { border-bottom: none; }
.cat-emoji { margin-right: 6px; }
.cat-multiplier { font-size: 12px; color: var(--text-dim); margin-left: 4px; }
.cat-value { font-weight: 700; color: var(--text); }
.total-row td { font-weight: 700; font-size: 15px; padding-top: 12px; border-top: 2px solid var(--border-light); border-bottom: none; color: var(--text); }

/* Fee summary */
.fee-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.fee-box { background: var(--surface-light); border-radius: var(--radius-sm); padding: 12px; text-align: center; border: 1px solid var(--border); }
.fee-box .fee-num { font-size: 18px; font-weight: 700; }
.fee-box .fee-lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.fee-num.green { color: var(--green); }
.fee-num.red { color: var(--red); }

/* Perks list */
.perks-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.perks-list li { font-size: 14px; display: flex; align-items: flex-start; gap: 8px; color: var(--text-muted); }
.perks-list li::before { content: "✓"; color: var(--purple-light); font-weight: 700; flex-shrink: 0; margin-top: 1px; }

/* Membership note */
.membership-note {
  background: rgba(99, 102, 241, 0.08); border: 1px solid rgba(99, 102, 241, 0.2); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; color: #a5b4fc; margin-bottom: 16px;
}
.membership-note strong { display: block; margin-bottom: 2px; color: #c7d2fe; }

/* Signup bonus */
.bonus-box {
  background: var(--purple-subtle); border: 1px solid rgba(139, 92, 246, 0.2); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 14px; color: var(--text-muted);
}
.bonus-box strong { color: var(--purple-light); }

/* Apply button */
.btn-apply-card {
  display: block; width: 100%;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white);
  text-align: center; padding: 14px; border-radius: var(--radius); text-decoration: none;
  font-size: 15px; font-weight: 700; transition: all 0.2s; margin-top: 8px;
  box-shadow: 0 4px 16px var(--purple-glow);
}
.btn-apply-card:hover { box-shadow: 0 6px 24px var(--purple-glow); transform: translateY(-1px); }

/* ---- COMPARE BAR ---- */
.compare-bar {
  position: fixed; bottom: -100px; left: 0; right: 0; z-index: 90;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--white); transition: bottom 0.3s ease;
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
}
.compare-bar.visible { bottom: 0; }
.compare-bar-inner { max-width: 1100px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.compare-slots { display: flex; gap: 12px; flex: 1; overflow: hidden; }
.compare-slot { font-size: 13px; color: var(--text-muted); }
.compare-slot strong { color: var(--text); display: block; }
.compare-actions { display: flex; gap: 10px; }
.btn-compare-view {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white); border: none; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 12px var(--purple-glow);
}
.btn-compare-view:hover { box-shadow: 0 4px 20px var(--purple-glow); }
.btn-compare-clear { background: none; border: 1.5px solid var(--border-light); color: var(--text-muted); padding: 10px 16px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.btn-compare-clear:hover { border-color: var(--text-muted); color: var(--text); }

/* ---- COMPARE MODAL ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); z-index: 200; backdrop-filter: blur(8px); overflow-y: auto; padding: 40px 24px; }
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }
.compare-modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 900px; overflow: hidden; border: 1px solid var(--border); }
.compare-modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.compare-modal-header h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.compare-table-wrap { padding: 24px; overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; min-width: 500px; }
.compare-table th { padding: 16px 12px; font-size: 14px; font-weight: 700; border-bottom: 2px solid var(--border-light); text-align: center; color: var(--text); }
.compare-table th:first-child { text-align: left; }
.compare-table td { padding: 12px; font-size: 14px; border-bottom: 1px solid var(--border); text-align: center; color: var(--text-muted); }
.compare-table td:first-child { text-align: left; font-weight: 600; color: var(--text-muted); }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:nth-child(even) td { background: var(--glass); }
.compare-winner { color: var(--purple-light); font-weight: 700; }

/* ---- FOOTER ---- */
.footer { background: var(--surface); color: var(--text-muted); padding: 32px 24px; border-top: 1px solid var(--border); }
.footer-inner { max-width: 1100px; margin: 0 auto; font-size: 13px; line-height: 1.7; }
.footer-inner strong { color: var(--text); }
.footer-note { margin-top: 8px; opacity: 0.6; }

/* ---- CAP WARNING CHIP (Phase 4) ---- */
.cap-warning {
  display: inline-block;
  font-size: 10px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

/* ---- BANKING RELATIONSHIPS / TIER REWARDS (Phase 3) ---- */
.banking-relationships {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.banking-summary {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  padding: 8px 0;
  list-style: none;
  user-select: none;
  flex-wrap: wrap;
}
.banking-summary::-webkit-details-marker { display: none; }
.banking-summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-dim);
  transition: transform 0.2s;
}
.banking-relationships[open] .banking-summary::after { transform: rotate(180deg); }
.banking-icon { font-size: 20px; }
.banking-title { font-size: 14px; font-weight: 700; color: var(--text); }
.banking-title em { font-style: normal; color: var(--text-dim); font-weight: 500; }
.banking-hint { font-size: 11px; color: var(--text-dim); flex-basis: 100%; padding-left: 30px; }

.banking-body {
  margin-top: 14px;
  display: flex; flex-direction: column; gap: 16px;
}
.banking-explainer {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
  padding: 10px 12px;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: var(--radius-sm);
}
.bank-relationship {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.bank-rel-header { display: flex; flex-direction: column; gap: 2px; }
.bank-rel-header strong { font-size: 14px; color: var(--text); }
.bank-rel-bank { font-size: 11px; color: var(--text-muted); }
.bank-rel-tiers {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.bank-rel-tiers label {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.bank-rel-tiers label:hover { border-color: var(--purple); }
.bank-rel-tiers input[type="radio"] { accent-color: var(--purple); }
.bank-rel-tiers label:has(input[type="radio"]:checked) {
  background: var(--purple-subtle);
  border-color: var(--purple);
  color: var(--text);
}
.bank-rel-balance { display: flex; flex-direction: column; gap: 4px; }
.bank-rel-balance label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.bank-rel-apy { display: flex; flex-direction: column; gap: 4px; }
.bank-rel-apy > label {
  font-size: 13px; color: var(--text); font-weight: 600;
}
.apy-hint { font-weight: 500; color: var(--text-muted); font-size: 11px; }
.input-wrap.apy-input { max-width: 140px; }
.input-wrap.apy-input span {
  border-right: none; border-left: 1.5px solid var(--border-light);
}

/* Tier section in detail drawer */
.tier-section { background: rgba(139, 92, 246, 0.04); border-radius: var(--radius); padding: 16px; }
.tier-section.is-boosted { background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.25); }
.tier-active-pill, .tier-eligible-pill {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  margin-left: 6px;
  vertical-align: 1px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tier-active-pill { background: var(--purple); color: var(--white); }
.tier-eligible-pill { background: var(--surface-light); color: var(--text-dim); border: 1px solid var(--border-light); }
.tier-cta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.tier-table {
  width: 100%; border-collapse: collapse; margin-bottom: 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tier-table th, .tier-table td {
  padding: 8px 10px;
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tier-table th {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); font-size: 10px;
}
.tier-table tr:last-child td { border-bottom: none; }
.tier-table tr.tier-current td {
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple-light);
  font-weight: 700;
}

.tier-true-net {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.tier-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--text-muted);
}
.tier-row strong { color: var(--text); }
.tier-row strong.green { color: var(--green); }
.tier-row strong.red { color: var(--red); }
.tier-row-divider { padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; }
.tier-row-final {
  font-size: 16px; font-weight: 700;
  border-top: 2px solid var(--border-light); padding-top: 10px;
  margin-top: 6px;
}
.tier-row-final.is-negative { color: var(--red); }
.tier-row-final span { color: var(--text); }
.tier-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 12px; line-height: 1.5;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin-top: 10px;
}

/* Wallet builder boost styling */
.wallet-use-chip em.boosted {
  color: #fbbf24; font-weight: 800;
}
.wallet-true-net-row {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 13px; color: var(--text-muted);
}
.wallet-true-net-row.is-negative .wallet-true-net-value { color: var(--red); }
.wallet-true-net-value { font-weight: 700; color: var(--text); }
.wallet-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 12px; line-height: 1.5;
  padding: 10px 12px; border-radius: var(--radius-sm);
  flex-basis: 100%;
}

/* ---- WALLET BUILDER (Phase 2) ---- */
.wallet-builder {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(139, 92, 246, 0.02));
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}
.wallet-builder-inner { max-width: 1100px; margin: 0 auto; }
.wallet-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.wallet-title h2 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 2px;
}
.wallet-sub { color: var(--text-muted); font-size: 12px; max-width: 540px; }

.wallet-mode-toggle {
  display: flex; flex-shrink: 0;
  background: var(--surface-light);
  border: 1.5px solid var(--border-light);
  border-radius: 999px; overflow: hidden;
  padding: 3px;
  gap: 2px;
}
.wallet-mode-btn {
  padding: 6px 14px; border: none; background: transparent;
  font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); white-space: nowrap;
  border-radius: 999px; transition: all 0.2s;
  font-family: var(--font);
}
.wallet-mode-btn:hover { color: var(--text-muted); }
.wallet-mode-btn.active {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px var(--purple-glow);
}

.wallet-result { display: flex; flex-direction: column; gap: 14px; }
.wallet-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.wallet-card {
  background: var(--surface-light);
  border: 1.5px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; flex-direction: column; gap: 10px;
}
.wallet-card:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.wallet-card:focus-visible {
  outline: 2px solid var(--purple); outline-offset: 2px;
}

.wallet-card-header {
  display: flex; align-items: center; gap: 10px;
}
.wallet-card-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(139, 92, 246, 0.1));
  color: var(--purple-light); border: 1.5px solid var(--purple);
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.wallet-card-logo {
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-lighter); border-radius: 6px;
  border: 1px solid var(--border); overflow: hidden;
}
.wallet-card-id {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.wallet-card-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wallet-card-issuer { font-size: 11px; color: var(--text-muted); }
.wallet-card-fee {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: var(--surface); padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border); white-space: nowrap; flex-shrink: 0;
}
.wallet-card-fee.no-fee { color: var(--green); }

.wallet-card-uses {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: 12px;
}
.wallet-uses-label {
  color: var(--text-dim); font-size: 11px;
  text-transform: uppercase; font-weight: 700; letter-spacing: 0.4px;
  margin-right: 2px;
}
.wallet-uses-empty { color: var(--text-dim); font-style: italic; }
.wallet-use-chip {
  background: var(--purple-subtle);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--text);
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.wallet-use-chip em {
  font-style: normal; color: var(--purple-light); font-weight: 700;
}

.wallet-summary {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.wallet-net-row { display: flex; align-items: baseline; gap: 10px; }
.wallet-net-label {
  font-size: 11px; text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.5px; color: var(--text-dim);
}
.wallet-net-value {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800; color: var(--green);
}
.wallet-comparison { font-size: 13px; color: var(--text-muted); }
.wallet-gain { color: var(--green); font-weight: 700; }

@media (max-width: 640px) {
  .wallet-builder { padding: 14px 12px; }
  .wallet-header { gap: 10px; margin-bottom: 12px; }
  .wallet-title h2 { font-size: 16px; }
  .wallet-sub { font-size: 11px; }
  .wallet-mode-toggle { width: 100%; }
  .wallet-mode-btn { flex: 1; padding: 7px 8px; font-size: 11px; }
  .wallet-cards-grid { grid-template-columns: 1fr; }
  .wallet-summary { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 4px; }
  .wallet-net-value { font-size: 19px; }
}

/* ---- TOASTS, SPINNERS, FLASH (Phase 1 UX feedback) ---- */
.toast-host {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  max-width: 360px;
}
.toast-enter { opacity: 1; transform: translateY(0); }
.toast-leave { opacity: 0; transform: translateY(12px); }
.toast-success { border-color: rgba(34, 197, 94, 0.4); }
.toast-success::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 8px;
  vertical-align: middle;
}

/* Loading spinner inside the Apply button */
.btn-apply.is-loading { opacity: 0.85; cursor: progress; }
.btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

/* Flash animation for top cards when ranking updates */
@keyframes flash-update {
  0%   { background: rgba(139, 92, 246, 0.0); box-shadow: inset 4px 0 0 rgba(139, 92, 246, 0); }
  20%  { background: rgba(139, 92, 246, 0.18); box-shadow: inset 4px 0 0 rgba(139, 92, 246, 1); }
  100% { background: rgba(139, 92, 246, 0.0); box-shadow: inset 4px 0 0 rgba(139, 92, 246, 0); }
}
.card-row.flash-update {
  animation: flash-update 0.65s ease-out;
}

/* Personalized profile dot (purple) */
.profile-dot.personalized { background: var(--purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }

/* Respect users who prefer no motion */
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.01s; transform: none; }
  .btn-spinner { animation: none; border-top-color: rgba(255,255,255,0.7); }
  .card-row.flash-update { animation: none; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .filter-row-top { flex-wrap: wrap; }
  .search-wrap { max-width: 100%; flex: 1; min-width: 150px; }
  .sort-wrap { flex: 0; }
}

/* ---- MOBILE: Transform card table into stacked cards ---- */
@media (max-width: 640px) {
  /* --- Header --- */
  .header { padding: 10px 16px; }
  .header-inner { gap: 8px; }
  .header-tagline { font-size: 12px; flex-basis: 100%; }
  .logo-text { font-size: 20px; }

  /* --- Hero --- */
  .hero { padding: 18px 16px 14px; }
  .hero h1 { font-size: 20px; line-height: 1.2; margin-bottom: 6px; }
  .hero p { font-size: 13px; margin-bottom: 12px; line-height: 1.4; }
  .hero-copy { margin-bottom: 10px; }
  .personalize-toggle-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .default-profile-label { font-size: 12px; justify-content: center; }
  .btn-personalize {
    padding: 12px 20px; font-size: 14px; width: 100%;
    justify-content: center; text-align: center;
  }

  /* --- Personalize drawer --- */
  .personalize-drawer.open { max-height: 900px; }
  .personalize-drawer-inner { padding: 20px 16px; }
  .spending-inputs { grid-template-columns: 1fr 1fr; gap: 12px; }
  .drawer-footer { flex-direction: column; }
  .btn-reset, .btn-apply { width: 100%; text-align: center; }

  /* --- Filter bar --- */
  .filter-bar-inner { padding: 8px 12px; gap: 8px; }
  .filter-row-top { gap: 8px; flex-wrap: wrap; }
  .search-wrap { max-width: 100%; order: 1; flex-basis: 100%; padding: 8px 14px; }
  .search-wrap input { font-size: 14px; }
  .sort-wrap { order: 2; flex: 1; }
  .sort-wrap select { flex: 1; font-size: 13px; min-height: 36px; }
  .results-count { order: 3; font-size: 11px; }
  .filter-chips { margin: 0 -12px; padding: 0 12px 2px; }
  .chip { padding: 6px 12px; font-size: 11px; min-height: 30px; }
  .filter-row-bottom { flex-wrap: wrap; gap: 6px; }
  .val-toggle-btn { padding: 6px 12px; font-size: 11px; }

  /* --- MAIN: Convert table to cards --- */
  .main { padding: 12px 12px 140px; }
  .table-wrap { overflow-x: visible; }

  /* Hide table head on mobile */
  .card-table thead { display: none; }

  /* Each row becomes a card */
  .card-table, .card-table tbody { display: block; }
  .card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    position: relative;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 54px 14px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .card-row:nth-child(even) { background: var(--surface-light); }
  .card-row:hover { background: var(--surface-lighter); box-shadow: var(--shadow-hover); }
  .card-row.selected {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.4);
  }
  .card-row td {
    display: block;
    padding: 0;
    border: none;
    font-size: 14px;
    min-width: 0;
  }

  /* Rank badge — absolute, top-left */
  .card-row .td-rank {
    position: absolute; top: 12px; left: 12px;
    grid-column: unset; grid-row: unset;
  }
  .card-row .td-rank span {
    width: 32px; height: 32px; font-size: 13px;
  }

  /* Card identity — full-width header */
  .card-row .td-card {
    grid-column: 1 / -1;
    padding-left: 40px; /* room for rank badge */
    padding-right: 36px; /* room for compare checkbox */
    min-height: 36px;
    display: flex;
    align-items: center;
  }
  .card-row .card-identity { gap: 10px; width: 100%; }
  .card-row .card-logo-inline { width: 32px; height: 32px; }
  .card-row .card-name {
    font-size: 14px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: block;
  }
  .card-row .card-issuer { font-size: 12px; }

  /* Compare checkbox — absolute, top-right */
  .card-row .td-compare {
    position: absolute; top: 14px; right: 14px;
    grid-column: unset; grid-row: unset;
  }
  .card-row .compare-check { width: 22px; height: 22px; }

  /* Stats cells — flow into the 2-col grid naturally */
  .card-row .td-rate,
  .card-row .td-earned,
  .card-row .td-fee,
  .card-row .td-net {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    min-width: 0;
    overflow: hidden;
  }
  .card-row .td-rate::before,
  .card-row .td-earned::before,
  .card-row .td-fee::before,
  .card-row .td-net::before {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 4px;
    order: -1;
  }
  .card-row .td-rate::before { content: "Eff. Rate"; }
  .card-row .td-earned::before { content: "Earned/yr"; }
  .card-row .td-fee::before { content: "Fee"; }
  .card-row .td-net::before { content: "Net Value"; }

  /* Apply button — full width at bottom */
  .card-row .td-apply {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 2px;
  }

  .card-row .rate-pct { font-size: 18px; font-weight: 800; }
  .card-row .rate-type { font-size: 11px; margin-top: 2px; }
  .card-row .td-earned { font-size: 17px; font-weight: 800; color: var(--text); }
  .card-row .td-fee { font-size: 17px; font-weight: 700; }
  .card-row .td-net { font-size: 19px; font-weight: 800; }
  .card-row .credits-tag {
    font-size: 10px; white-space: normal; line-height: 1.3; margin-top: 3px;
  }
  .card-row .no-fee { font-size: 17px; }

  /* Apply link — full-width bottom */
  .card-row .td-apply { text-align: center; margin-top: 2px; }
  .card-row .apply-link {
    display: block; padding: 11px 16px; font-size: 14px;
    border-radius: 10px; min-height: 44px;
    line-height: 22px;
  }

  /* Empty state */
  .loading-state { padding: 40px 16px; }

  /* --- Detail drawer --- */
  .detail-drawer { max-width: 100%; width: 100%; right: -100%; }
  .detail-drawer-header { padding: 16px 18px; gap: 12px; }
  .detail-drawer-body { padding: 18px; }
  .detail-drawer-header h2 { font-size: 16px; }
  .detail-logo { width: 44px; height: 44px; font-size: 20px; }
  .value-highlight-box { padding: 16px; }
  .value-highlight-box .big-number { font-size: 34px; }
  .fee-summary { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .fee-box { padding: 10px 6px; }
  .fee-box .fee-num { font-size: 15px; }
  .fee-box .fee-lbl { font-size: 10px; }

  /* --- Compare bar --- */
  .compare-bar-inner {
    padding: 10px 12px; gap: 10px;
    flex-wrap: wrap;
  }
  .compare-slots { display: none; }
  .compare-actions { flex: 1; justify-content: space-between; gap: 8px; }
  .btn-compare-view { flex: 1; padding: 10px 14px; font-size: 13px; }
  .btn-compare-clear { padding: 10px 14px; font-size: 13px; }

  /* --- Compare modal --- */
  .modal-overlay { padding: 20px 12px; }
  .compare-modal-header { padding: 16px 18px; }
  .compare-modal-header h2 { font-size: 17px; }
  .compare-table-wrap { padding: 14px; }

  /* --- Valuation help popover --- */
  .val-help-content { padding: 18px; max-height: 80vh; overflow-y: auto; }

  /* --- Footer --- */
  .footer { padding: 24px 16px; }
  .footer-inner { font-size: 12px; }

  /* Hide acronym tooltip positioning on mobile (hover doesn't exist well) */
  .acronym-help:hover::after { width: 180px; font-size: 11px; }
}

/* Extra small: <= 380px */
@media (max-width: 380px) {
  .card-row { padding: 48px 10px 10px; gap: 6px; }
  .card-row .td-rank { top: 10px; left: 10px; }
  .card-row .td-rank span { width: 28px; height: 28px; font-size: 12px; }
  .card-row .td-compare { top: 12px; right: 12px; }
  .card-row .td-card { padding-left: 34px; padding-right: 32px; min-height: 32px; }
  .card-row .card-name { font-size: 13px; }
  .card-row .card-logo-inline { width: 28px; height: 28px; }
  .card-row .td-rate,
  .card-row .td-earned,
  .card-row .td-fee,
  .card-row .td-net { padding: 8px 10px; }
  .card-row .rate-pct { font-size: 16px; }
  .card-row .td-earned,
  .card-row .td-fee,
  .card-row .td-net { font-size: 15px; }
  .hero h1 { font-size: 18px; }
  .spending-inputs { grid-template-columns: 1fr; }
}
