/* Rewards page. Tokens come from patient-app.css (loaded first). */
[data-crr-wallet] {
  --crr-plum: var(--pt-plum, #351750);
  --crr-muted: var(--pt-muted, #5f5569);
  --crr-line: var(--pt-line, #e4dbea);
  --crr-surface: var(--pt-plum-soft, #f5f0f8);
  --crr-card: var(--pt-white, #fff);
}

.crr-launch-account > span { margin-inline-start: auto; font-size: 22px; }

.crr-page { color: var(--pt-ink, #22152f); font: 1rem/1.55 var(--pt-font, Poppins, system-ui, sans-serif); }
.crr-page [hidden] { display: none !important; }
.crr-body { display: grid; gap: clamp(.75rem, 2vw, 1rem); }
.crr-page p { margin: 0; }
.crr-page p, .crr-history small { color: var(--crr-muted); }

/* Section switcher */
.crr-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--pt-plum-tint, #ebe2f1);
}
.crr-page .crr-tabs button { min-height: 44px; padding: .5rem .5rem; border: 0; border-radius: 999px; background: transparent; color: var(--crr-plum); font-weight: 600; }
.crr-page .crr-tabs button[aria-pressed="true"] { background: var(--crr-card); box-shadow: 0 1px 4px rgb(53 23 80 / .18); }

/* Balance */
.crr-overview {
  padding: clamp(1.125rem, 3vw, 1.5rem);
  border-radius: var(--pt-radius, 14px);
  background: var(--crr-plum);
  color: #fff;
}
.crr-overview p, .crr-overview dt { color: rgb(255 255 255 / .78); }
.crr-total { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 1rem; }
.crr-total > span { grid-column: 1; color: rgb(255 255 255 / .82); font-size: .9375rem; }
.crr-total strong { font-size: clamp(2.25rem, 8vw, 3rem); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.crr-page .crr-balance-link { grid-column: 2; grid-row: 1 / span 2; min-height: 48px; padding: .6rem 1.25rem; border-radius: 12px; background: var(--pt-mint, #cdf7b7); color: var(--crr-plum); }
.crr-page .crr-balance-link:hover { background: var(--pt-mint-strong, #b2ec95); }
.crr-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem 1rem; margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid rgb(255 255 255 / .18); }
.crr-metrics dt { font-size: .8125rem; }
.crr-metrics dd { margin: 0; color: #fff; font-weight: 700; overflow-wrap: anywhere; }

/* Cards */
.crr-card { min-width: 0; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--crr-line); border-radius: var(--pt-radius, 14px); background: var(--crr-card); box-shadow: var(--pt-shadow, none); }
.crr-card h2 { margin: 0 0 .5rem; color: var(--crr-plum); font-size: 1.125rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.crr-card > p + p, .crr-overview > p { margin-top: .6rem; }
.crr-small { font-size: .875rem; }
.crr-tag { display: inline-block; margin-top: .5rem !important; padding: .25rem .65rem; border-radius: 999px; background: var(--pt-mint-soft, #f0fbea); color: var(--pt-ok, #24541a) !important; font-size: .875rem; font-weight: 600; }

/* Referral code */
.crr-code { display: flex; align-items: stretch; gap: .5rem; margin-top: 1rem; }
.crr-code code {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  min-height: 52px;
  padding: .5rem 1rem;
  border: 1.5px dashed #c9b8d6;
  border-radius: 12px;
  background: var(--crr-surface);
  color: var(--crr-plum);
  font: 700 clamp(1rem, 4.5vw, 1.25rem)/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .08em;
  overflow-wrap: anywhere;
  user-select: all;
}
.crr-page .crr-code button { min-width: 6rem; min-height: 52px; border-radius: 12px; background: var(--crr-plum); color: #fff; }

/* Progress */
.crr-progress ol { display: grid; gap: .5rem; margin: .75rem 0; padding: 0; list-style: none; counter-reset: reward-step; }
.crr-progress li { counter-increment: reward-step; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 .75rem; padding: .75rem; border-radius: 12px; background: var(--crr-surface); }
.crr-progress li::before { content: counter(reward-step); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--crr-line); border-radius: 50%; background: #fff; color: var(--crr-plum); font-size: .8125rem; font-weight: 700; }
.crr-progress li.is-complete::before { content: "✓"; border-color: var(--pt-mint, #cdf7b7); background: var(--pt-mint, #cdf7b7); }
.crr-progress li span { color: var(--crr-muted); font-size: .875rem; }
.crr-progress li.is-complete span { color: var(--pt-ok, #24541a); font-weight: 600; }

/* Qualifying products */
.crr-products { display: grid; gap: .5rem; margin: .75rem 0 .5rem; padding: 0; list-style: none; }
.crr-products li { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem; border: 1px solid var(--crr-line); border-radius: 12px; }
.crr-products img { width: 56px; height: 56px; border-radius: 10px; object-fit: contain; background: var(--crr-surface); }
.crr-products li > div { flex: 1 1 8rem; min-width: 0; display: grid; gap: 2px; }
.crr-products li strong { overflow-wrap: anywhere; }
.crr-products li span { color: var(--crr-muted); }
.crr-product-link { flex: 0 0 auto; display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .5rem 1rem; border: 1.5px solid var(--crr-line); border-radius: 12px; color: var(--crr-plum) !important; font-weight: 600; text-decoration: none; }
.crr-product-link:hover { border-color: var(--crr-plum); }

/* Forms and buttons */
.crr-form, .crr-form label { display: grid; gap: 6px; }
.crr-form { gap: .75rem; margin: .75rem 0 .5rem; }
.crr-form label { min-width: 0; color: var(--pt-ink, #22152f); font-size: .9375rem; font-weight: 600; }
.crr-form input { width: 100%; min-width: 0; min-height: 48px; padding: .6rem .8rem; border: 1px solid #cfc2d8; border-radius: 10px; background: #fff; color: var(--pt-ink, #22152f); font: inherit; }
.crr-form input:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--pt-danger, #a12833); }
.crr-bank-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.crr-bank-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .75rem; margin-top: .75rem; padding: .75rem 1rem; border-radius: 12px; background: var(--crr-surface); }
.crr-page :where(button) { min-height: 48px; padding: .6rem 1.25rem; border: 1.5px solid transparent; border-radius: 12px; background: var(--crr-plum); color: #fff; font: inherit; font-weight: 600; overflow-wrap: anywhere; cursor: pointer; }
.crr-page :where(button):hover { background: var(--pt-plum-strong, #24103a); }
.crr-page button.crr-secondary { border-color: var(--crr-line); background: #fff; color: var(--crr-plum); }
.crr-page button.crr-secondary:hover { border-color: var(--crr-plum); background: var(--crr-surface); }
.crr-form button { justify-self: start; }
.crr-page button:disabled { opacity: .65; cursor: progress; }
.crr-page :focus-visible { outline: 3px solid var(--crr-plum); outline-offset: 2px; }
.crr-overview :focus-visible { outline-color: var(--pt-mint, #cdf7b7); }
.crr-page details { margin-top: .75rem; border-top: 1px solid var(--crr-line); }
.crr-page summary { min-height: 44px; padding: .75rem 0 .25rem; color: var(--crr-plum); font-weight: 600; cursor: pointer; }

/* History and status */
.crr-history { margin: .25rem 0 0; padding: 0; list-style: none; }
.crr-history li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); justify-content: space-between; gap: .5rem 1rem; align-items: start; padding: .85rem 0; border-top: 1px solid var(--crr-line); }
.crr-history li:first-child { border-top: 0; }
.crr-history li :is(div, small, strong, span) { min-width: 0; overflow-wrap: anywhere; }
.crr-history small { display: block; font-size: .8125rem; }
.crr-history li > span { font-weight: 700; }
.crr-history-result { max-width: 11rem; text-align: end; }
.crr-status { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; margin: .2rem 0; padding: 0 .6rem; border-radius: 999px; background: var(--crr-surface); color: var(--crr-plum); font-size: .75rem; font-weight: 600; }
.crr-history-result .crr-status { margin-inline-start: auto; }
.crr-status--requested, .crr-status--processing { background: var(--pt-warn-bg, #fff4d4); color: var(--pt-warn, #6a4a00); }
.crr-status--paid { background: var(--pt-mint-soft, #f0fbea); color: var(--pt-ok, #24541a); }
.crr-status--rejected { background: var(--pt-danger-bg, #fdecee); color: var(--pt-danger, #a12833); }
.crr-referral-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0 1rem; }
.crr-referral-totals > div { padding: .75rem; border-radius: 12px; background: var(--crr-surface); overflow-wrap: anywhere; }
.crr-referral-totals dt { color: var(--crr-muted); font-size: .8125rem; }
.crr-referral-totals dd { margin: .2rem 0 0; font-weight: 700; }
.crr-page-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.crr-page-controls span { color: var(--crr-muted); font-size: .875rem; }
.crr-page-controls[aria-busy="true"] button { pointer-events: none; }
#crr-referral-history, #crr-bank-transfer { scroll-margin-top: 6rem; }

.crr-page .crr-status-message:empty { display: none; }
.crr-page .crr-status-message { margin-bottom: .75rem; padding: .75rem 1rem; border-radius: 12px; background: var(--pt-mint-soft, #f0fbea); color: var(--pt-ok, #24541a); font-weight: 600; }
.crr-page .crr-status-message.is-error { background: var(--pt-danger-bg, #fdecee); color: var(--pt-danger, #a12833); }
.crr-page .crr-status-message:focus { outline: none; }

/* Loading and error states */
.crr-skeleton { display: grid; gap: .75rem; }
.crr-skeleton span { display: block; height: 9rem; border-radius: var(--pt-radius, 14px); background: linear-gradient(90deg, var(--crr-surface) 25%, #fff 50%, var(--crr-surface) 75%) 0 0 / 200% 100%; animation: crr-shimmer 1.2s linear infinite; }
.crr-skeleton span:first-child { height: 3.25rem; border-radius: 999px; }
.crr-skeleton span:last-child { height: 6rem; }
@keyframes crr-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .crr-skeleton span { animation: none; } }
.crr-error { text-align: center; }
.crr-error button { margin-top: 1rem; }

@media (max-width: 600px) {
  .crr-referral-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crr-page .crr-tabs button { font-size: .875rem; }
}
@media (max-width: 380px) {
  .crr-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crr-bank-inputs { grid-template-columns: minmax(0, 1fr); }
  .crr-total { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .crr-page .crr-balance-link { grid-column: 1; grid-row: auto; justify-self: start; }
}
.crr-page .crr-tabs button { white-space: nowrap; }
@media (max-width: 360px) {
  .crr-page .crr-tabs button { padding-inline: .25rem; font-size: .8125rem; }
}
