/* =============================================================
   Raise to Work — Design System
   Mobile-first. Audience: volunteers, older users, vulnerable
   populations. Priorities: large tap targets, high contrast,
   plain language, predictable patterns.
   ============================================================= */

/* ---- 1. Tokens ------------------------------------------------ */
:root {
    /* Brand — single primary color (blue), no secondary accent.
       Brand-blue / brand-green tokens preserved for the logo only. */
    --color-primary:        #0284C7;   /* sky blue — matches Foqas family, AA on white */
    --color-primary-dark:   #075985;   /* hover/active */
    --color-primary-darker: #0C4A6E;   /* deepest blue, headings/emphasis */
    --color-primary-soft:   #E0F2FE;   /* tints/backgrounds */
    --color-brand-blue:     #449ED7;   /* exact Foqas brand blue, logo accent only */
    --color-brand-green:    #C7D830;   /* exact RYU green, logo accent only */

    /* Status */
    --color-success:        #15803D;
    --color-warning:        #B45309;
    --color-danger:         #B91C1C;

    /* Neutrals — cool slate scale to complement the blue brand. */
    --color-bg:             #F1F5F9;   /* slate-100 — soft cool background, cards pop on it */
    --color-surface:        #FFFFFF;   /* card / form surfaces */
    --color-border:         #E2E8F0;   /* slate-200 */
    --color-border-strong:  #CBD5E1;   /* slate-300 — input borders */
    --color-text:           #0F172A;   /* slate-900, AAA on bg, also matches logo fill */
    --color-text-muted:     #475569;   /* slate-600 */
    --color-text-subtle:    #64748B;   /* slate-500 */

    /* Type — base 18px for older users */
    --font-sans:            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --text-xs:   0.875rem;   /* 14 — captions only */
    --text-sm:   1rem;       /* 16 — secondary text */
    --text-base: 1.125rem;   /* 18 — body */
    --text-lg:   1.25rem;    /* 20 */
    --text-xl:   1.5rem;     /* 24 */
    --text-2xl:  1.875rem;   /* 30 */
    --text-3xl:  2.25rem;    /* 36 */

    --leading-tight:  1.25;
    --leading-normal: 1.5;
    --leading-loose:  1.7;

    /* Spacing — 4px scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Tap targets — 56px primary, 48px minimum */
    --tap-target:        3.5rem;   /* 56px */
    --tap-target-min:    3rem;     /* 48px */

    /* Radius */
    --radius-sm:  0.375rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.75rem;
    --radius-xl:  1rem;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md:  0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg:  0 12px 32px rgba(15, 23, 42, 0.12);

    /* Focus ring — visible to everyone, especially keyboard users */
    --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.45);

    /* Layout */
    --max-content-width: 720px;     /* narrow reading column — used by auth pages */
    --max-app-width:     1320px;    /* wide app shell — dashboards, lists, forms */
    --header-height:     4rem;
    --bottom-nav-height: 4.5rem;
}

/* ---- 2. Reset / base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-bg);
    /* Flex column layout lets the bottom nav use position: sticky bottom: 0
       instead of position: fixed. Sticky stays in document flow, which iOS
       Safari handles correctly during chrome transitions and overscroll —
       avoids the "nav stuck mid-screen" glitch position: fixed has on iOS. */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

/* iOS / mobile Safari aggressively re-styles native <button> with its own
   gray rounded appearance, which overrides our custom backgrounds, borders,
   and shapes. Reset appearance on every custom button class so the design
   system's styling actually wins. */
.r2w-btn,
.r2w-wl-tab,
.r2w-pill-action,
.r2w-action,
.r2w-btn-clear,
.r2w-icon-picker__opt,
.r2w-cloth-item__remove,
.r2w-fab-pager,
.r2w-fab-scroll,
.r2w-bottom-nav__item--more,
.r2w-drawer__btn {
    -webkit-appearance: none;
    appearance: none;
}

a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
a:hover { color: var(--color-primary-dark); }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

h1, h2, h3, h4 {
    margin: 0 0 var(--space-3);
    line-height: var(--leading-tight);
    font-weight: 600;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

/* ---- 3. Layout primitives ------------------------------------ */
.r2w-container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.r2w-stack > * + * { margin-top: var(--space-4); }
.r2w-stack-lg > * + * { margin-top: var(--space-6); }

/* Auth layout — full-height centered, no nav */
.r2w-auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
}
.r2w-auth__inner {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}
.r2w-auth__brand {
    text-align: center;
    margin-bottom: var(--space-8);
    color: var(--color-text);   /* used by SVG logo via currentColor */
}
/* Supporters block — footer below the form. */
.r2w-auth__supporters {
    margin-top: var(--space-10);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
    text-align: center;
}
.r2w-auth__supporters-label {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 var(--space-4);
}
.r2w-auth__logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
}
.r2w-auth__logo {
    display: block;
    height: auto;
}
.r2w-auth__logo--r2w {
    width: 5rem;        /* 80px */
}
.r2w-auth__logo--foqas {
    width: 8rem;        /* 128px */
}
.r2w-auth__logo-divider {
    width: 1px;
    height: 2.5rem;
    background: var(--color-border-strong);
    flex-shrink: 0;
}
.r2w-auth__brand-name {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.01em;
    margin: 0;
}
.r2w-auth__brand-tagline {
    margin: var(--space-1) 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ---- 4. Card ------------------------------------------------- */
.r2w-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.r2w-card__title {
    font-size: var(--text-xl);
    margin: 0 0 var(--space-5);
}
/* If a subtitle follows the title, pull it tighter so they read as a pair. */
.r2w-card__title:has(+ .r2w-card__subtitle) {
    margin-bottom: var(--space-2);
}
.r2w-card__subtitle {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin: 0 0 var(--space-5);
}

/* ---- 5. Form field ------------------------------------------- */
.r2w-field { display: flex; flex-direction: column; gap: var(--space-2); }
.r2w-field + .r2w-field { margin-top: var(--space-5); }

.r2w-field__label {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
}

.r2w-field__input,
.r2w-field__select,
.r2w-field__textarea {
    width: 100%;
    min-height: var(--tap-target);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-surface);
    border: 2px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    -webkit-appearance: none;
    appearance: none;
}
.r2w-field__textarea { min-height: 8rem; padding-top: var(--space-3); }
.r2w-field__input:hover,
.r2w-field__select:hover,
.r2w-field__textarea:hover { border-color: var(--color-text-muted); }

.r2w-field__input:focus,
.r2w-field__select:focus,
.r2w-field__textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}

.r2w-field__hint {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.r2w-field--error .r2w-field__input,
.r2w-field--error .r2w-field__select,
.r2w-field--error .r2w-field__textarea {
    border-color: var(--color-danger);
}
.r2w-field__error {
    font-size: var(--text-sm);
    color: var(--color-danger);
    font-weight: 500;
}

/* ---- 6. Button ----------------------------------------------- */
.r2w-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;                        /* full-width on mobile by default */
    min-height: var(--tap-target);
    padding: var(--space-3) var(--space-5);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease, transform 60ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-btn:active { transform: translateY(1px); }
.r2w-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.r2w-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.r2w-btn--primary {
    background: var(--color-primary);
    color: #FFFFFF;
}
.r2w-btn--primary:hover { background: var(--color-primary-dark); color: #FFF; }

.r2w-btn--secondary {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.r2w-btn--secondary:hover { background: var(--color-primary-soft); }

.r2w-btn--ghost {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.r2w-btn--ghost:hover { background: var(--color-bg); border-color: var(--color-text-muted); }

@media (min-width: 600px) {
    .r2w-btn--inline { width: auto; }
}

/* Compact pill-style header action — secondary in-page button used in
   page headers (e.g., "+ Add neighbor"). Smaller than primary form buttons. */
.r2w-pill-action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 2.25rem;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border: 1px solid var(--color-brand-blue);
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 120ms ease, border-color 120ms ease;
    flex-shrink: 0;
}
.r2w-pill-action:hover {
    background: var(--color-brand-blue);
    color: #FFFFFF;
    border-color: var(--color-brand-blue);
}
.r2w-pill-action:active { transform: scale(0.97); }
.r2w-pill-action:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.r2w-pill-action svg { width: 0.95rem; height: 0.95rem; }

/* Wider card variant for forms — narrow on mobile, weblike width on desktop. */
.r2w-form-card {
    max-width: 36rem;
}
@media (min-width: 768px) {
    .r2w-form-card { max-width: 52rem; }
}

/* Two-column form grid on tablet+. Textareas auto-span both columns via :has().
   Mobile keeps the natural single-column flow from .r2w-field margins. */
@media (min-width: 768px) {
    .r2w-form-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: var(--space-4);
        row-gap: var(--space-5);
    }
    .r2w-form-grid > .r2w-field + .r2w-field { margin-top: 0; }
    .r2w-form-grid > .r2w-field:has(textarea) { grid-column: 1 / -1; }
    .r2w-form-grid > .r2w-field--full { grid-column: 1 / -1; }
}

/* Form action row — Save / Cancel pair. Stacks on mobile, side-by-side on tablet+. */
.r2w-form-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-6);
}
@media (min-width: 600px) {
    .r2w-form-actions { flex-direction: row; }
    .r2w-form-actions .r2w-btn { width: auto; min-width: 8rem; }
}

/* ---- 7. Helpers / utilities ---------------------------------- */
.r2w-text-center { text-align: center; }
.r2w-text-muted { color: var(--color-text-muted); }
.r2w-text-sm { font-size: var(--text-sm); }
.r2w-mt-2 { margin-top: var(--space-2); }
.r2w-mt-4 { margin-top: var(--space-4); }
.r2w-mt-6 { margin-top: var(--space-6); }

.r2w-divider {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-6) 0;
}

/* ---- 8. Alerts (form errors / messages) ---------------------- */
.r2w-alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    line-height: 1.45;
    font-weight: 500;
    border: 1px solid transparent;
    border-left-width: 4px;
}
.r2w-alert--error {
    background: #FEF2F2;
    border-color: var(--color-danger);
    color: #7F1D1D;
}
.r2w-alert--success {
    background: #F0FDF4;
    border-color: var(--color-success);
    color: #14532D;
}
.r2w-alert--info {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
    color: var(--color-primary-darker);
}

/* ---- 8.5 HTMX progress bar + tap feedback ------------------- */
.r2w-progress-bar {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: var(--color-primary);
    z-index: 200;
    transition: width 200ms ease;
    pointer-events: none;
    opacity: 0;
}
.r2w-progress-bar.is-loading {
    opacity: 1;
    width: 80%;            /* climbs to 80% during request, then 100% on done */
    transition: width 1.5s cubic-bezier(0.1, 0.7, 0.1, 1);
}
.r2w-progress-bar.is-done {
    opacity: 1;
    width: 100%;
    transition: width 200ms ease;
}

/* Instant tap feedback on nav items so taps feel responsive even before the
   network request returns. */
.r2w-bottom-nav__item:active,
.r2w-topnav-link:active {
    background: var(--color-primary-soft);
    transition: background 0ms;
}

/* HTMX adds .htmx-request to the element making the request — show pressed state */
.r2w-bottom-nav__item.htmx-request,
.r2w-topnav-link.htmx-request {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

/* HTMX hides .htmx-indicator by default and shows it during a request. */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ---- 9. App shell — topbar + main + bottom nav + drawer ------ */

.r2w-app {
    /* Flex column so bottom-nav can sit at the end of the document and
       use position: sticky (which iOS Safari handles much better than
       position: fixed during chrome show/hide animations). */
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* --- Topbar --- */
.r2w-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    /* Force own compositing layer so camera <video> elements don't paint on top
       of the topbar on mobile (known iOS/Android WebView quirk). */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
.r2w-topbar__inner {
    max-width: var(--max-app-width);
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.r2w-topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--color-text);
    flex-shrink: 0;
}
.r2w-topbar__brand:hover { color: var(--color-text); }
.r2w-topbar__logo { width: 2rem; height: 2rem; flex-shrink: 0; }
.r2w-topbar__brand-name {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.01em;
    line-height: 1;
}

.r2w-topbar__nav {
    display: none;        /* hidden on mobile, shown on desktop */
    margin-left: var(--space-4);
    gap: var(--space-1);
    flex: 1;
}
.r2w-topbar__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.r2w-topbar__user-name {
    display: none;        /* hidden on mobile to save space */
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

@media (min-width: 768px) {
    .r2w-topbar__nav   { display: flex; }
    .r2w-topbar__user-name { display: inline; }
}

/* Topbar nav links */
.r2w-topnav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 2.5rem;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 120ms ease, color 120ms ease;
}
.r2w-topnav-link__icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}
.r2w-topnav-link:hover { background: var(--color-bg); color: var(--color-text); }
.r2w-topnav-link.is-active {
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

/* --- Main content --- */
.r2w-main {
    /* flex: 1 stretches main to fill the space between the fixed topbar and
       the sticky bottom-nav, so the nav naturally sits at viewport bottom
       on short pages and sticks during scroll on tall pages. */
    flex: 1;
    /* Top padding clears the fixed topbar; bottom-nav is in flow now
       (sticky), so no bottom-padding needed for it. */
    padding-top: calc(var(--header-height) + var(--space-5));
    padding-right: var(--space-4);
    padding-bottom: var(--space-6);
    padding-left: var(--space-4);
}
.r2w-main__inner {
    max-width: var(--max-app-width);
    margin: 0 auto;
    width: 100%;
}
@media (min-width: 768px) {
    .r2w-main { padding-bottom: var(--space-8); }   /* no bottom-nav on desktop */
}

/* --- Bottom nav (mobile only) --- */
.r2w-bottom-nav {
    /* position: sticky (with body+app as flex columns above) replaces the
       previous position: fixed. Sticky stays in document flow, which iOS
       Safari does NOT glitch during URL-bar show/hide animations — fixed
       did. Net effect for the user is identical: nav sits at viewport
       bottom on short pages, sticks at viewport bottom while scrolling
       on tall pages. */
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    height: var(--bottom-nav-height);
    /* Extend the nav background past the iPhone home-indicator strip
       (viewport-fit=cover places it inside the viewport). */
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-sizing: content-box;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
}
.r2w-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    padding: var(--space-2) var(--space-1);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: var(--bottom-nav-height);
}
.r2w-bottom-nav__item:hover { color: var(--color-text); }
.r2w-bottom-nav__item.is-active {
    color: var(--color-primary);
}
.r2w-bottom-nav__item.is-active .r2w-bottom-nav__icon {
    color: var(--color-primary);
}
.r2w-bottom-nav__icon { width: 1.5rem; height: 1.5rem; }
.r2w-bottom-nav__label { line-height: 1; }

@media (min-width: 768px) {
    .r2w-bottom-nav { display: none; }
}

/* --- Drawer (overlay menu, used on mobile via 'More') --- */
.r2w-drawer-toggle { /* hidden checkbox controls open/close */
    /* Fixed in the viewport so focusing it never triggers scroll-into-view
       (which was making mobile pages jump to the top when the drawer opened). */
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
    border: 0;
}
.r2w-drawer-toggle:focus { outline: none; }
.r2w-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 60;
}
.r2w-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 320px);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 220ms ease;
    z-index: 70;
    display: flex;
    flex-direction: column;
    padding: var(--space-4) 0;
    overflow-y: auto;
}
.r2w-drawer-toggle:checked ~ .r2w-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}
.r2w-drawer-toggle:checked ~ .r2w-drawer {
    transform: translateX(0);
}
.r2w-drawer__header {
    padding: var(--space-3) var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-2);
}
.r2w-drawer__title {
    font-size: var(--text-base);
    font-weight: 600;
    margin: 0;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.r2w-drawer__close {
    background: transparent;
    border: 0;
    padding: var(--space-2);
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.r2w-drawer__close:hover { background: var(--color-bg); color: var(--color-text); }
.r2w-drawer__close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.r2w-drawer__link,
.r2w-drawer__btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    min-height: var(--tap-target-min);
}
.r2w-drawer__link:hover,
.r2w-drawer__btn:hover { background: var(--color-bg); color: var(--color-text); }
.r2w-drawer__link.is-active { background: var(--color-primary-soft); color: var(--color-primary); }
.r2w-drawer__icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; color: var(--color-text-muted); }
.r2w-drawer__link.is-active .r2w-drawer__icon { color: var(--color-primary); }
.r2w-drawer__divider {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-2) 0;
}

@media (min-width: 768px) {
    /* On desktop, the drawer is reachable from a top-bar profile button */
    .r2w-bottom-nav__item--more { display: none; }
}

/* --- Page header (use inside r2w-main for page titles) --- */
.r2w-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.r2w-page-header__title {
    font-size: var(--text-2xl);
    margin: 0;
}

/* ---- 9.9 SPA tab panels + skeleton ----------------------- */
.r2w-tab-panel { display: none; }
.r2w-tab-panel.is-active { display: block; }

/* Skeleton placeholder: animated soft-pulse block while content loads */
.r2w-skel {
    background: var(--color-border);
    border-radius: var(--radius-sm);
    color: transparent;
    user-select: none;
    animation: r2w-skel-pulse 1.4s ease-in-out infinite;
}
@keyframes r2w-skel-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}
.r2w-skel--block { display: block; height: 1rem; width: 100%; }

.r2w-tab-loading {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

/* ---- 10. Dashboard widgets ----------------------------------- */

.r2w-greeting {
    margin-bottom: var(--space-2);
    min-width: 0;     /* allow flex/grid children to truncate */
}
.r2w-greeting__title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;     /* long emails wrap at any character so they don't overflow */
    line-height: 1.3;
}
.r2w-greeting__date {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin: var(--space-1) 0 0;
}

.r2w-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: var(--space-6) 0 var(--space-3);
}

.r2w-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}
@media (min-width: 600px) {
    .r2w-stat-grid--3 { grid-template-columns: repeat(3, 1fr); }
    .r2w-stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

.r2w-stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 6rem;
}
.r2w-stat--hero {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #FFFFFF;
    border-color: transparent;
}
.r2w-stat--hero .r2w-stat__label,
.r2w-stat--hero .r2w-stat__value,
.r2w-stat--hero .r2w-stat__sub {
    color: #FFFFFF;
}
.r2w-stat--hero .r2w-stat__label { color: rgba(255,255,255,0.85); }
.r2w-stat--hero .r2w-stat__sub   { color: rgba(255,255,255,0.75); }

.r2w-stat__label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}
.r2w-stat__value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}
.r2w-stat__sub {
    font-size: var(--text-sm);
    color: var(--color-text-subtle);
    margin-top: auto;
}

/* Quick actions */
.r2w-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}
@media (min-width: 600px) {
    .r2w-actions { grid-template-columns: repeat(3, 1fr); }
}
.r2w-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--color-text);
    min-height: 6.5rem;
    transition: border-color 120ms ease, transform 120ms ease;
}
.r2w-action:hover {
    border-color: var(--color-primary);
    color: var(--color-text);
    transform: translateY(-1px);
}
.r2w-action__icon {
    width: 2rem;
    height: 2rem;
    color: var(--color-primary);
    flex-shrink: 0;
}
.r2w-action__label {
    font-weight: 600;
    font-size: var(--text-base);
    line-height: 1.2;
}

/* Money summary (in vs out) */
.r2w-money-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}
.r2w-money {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}
.r2w-money__label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.r2w-money__value {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-top: var(--space-2);
}
.r2w-money__value--in   { color: var(--color-success); }
.r2w-money__value--out  { color: var(--color-danger); }
.r2w-money__icon {
    width: 1rem; height: 1rem;
}

/* ---- 10.3 Definition list (label/value pairs) --------------- */
.r2w-defs { margin: 0; }
.r2w-defs__row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.r2w-defs__row:last-child { border-bottom: 0; }
.r2w-defs__row:first-child { padding-top: 0; }
.r2w-defs dt {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0;
}
.r2w-defs dd { margin: 0; color: var(--color-text); }

/* QR card (used in neighbour view + similar) */
.r2w-qr-card {
    text-align: center;
    padding: var(--space-5) var(--space-4);
}
.r2w-qr-card__hint {
    margin: 0 0 var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.r2w-qr-card__image {
    display: block;
    max-width: 220px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}
.r2w-qr-card__id {
    margin: var(--space-3) 0 0;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    word-break: break-all;
}

/* Two-column layout for view-style pages on tablet+ */
.r2w-view-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}
@media (min-width: 768px) {
    .r2w-view-grid--with-qr {
        grid-template-columns: 18rem 1fr;
        align-items: start;
    }
}

/* ---- 10.4 Result list (search results, etc.) ---------------- */
.r2w-result-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.r2w-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    min-height: 3.5rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-result-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
}
.r2w-result-item:active { transform: scale(0.99); }
.r2w-result-item__main { flex: 1; min-width: 0; }
.r2w-result-item__name {
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.r2w-result-item__meta {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.r2w-result-item__chevron {
    color: var(--color-text-subtle);
    flex-shrink: 0;
    font-size: 1.5rem;
    line-height: 1;
}

/* List layout — filters on the side on desktop, stacked on mobile.
   Use for any "filter form + result list" page (donations, expenses, etc.) */
.r2w-list-layout {
    display: block;
}
.r2w-list-layout__filters,
.r2w-list-layout__results {
    max-width: 36rem;       /* mobile cap — readable single column */
}
@media (min-width: 900px) {
    .r2w-list-layout {
        display: grid;
        grid-template-columns: 1fr 20rem;     /* results left, filters right */
        gap: var(--space-6);
        align-items: start;
    }
    .r2w-list-layout__filters {
        max-width: none;
        order: 2;                             /* sit on the right on desktop */
        position: sticky;
        top: calc(var(--header-height) + var(--space-4));
        padding: var(--space-5);
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
    }
    .r2w-list-layout__results {
        max-width: none;
        order: 1;                             /* sit on the left on desktop */
    }

    /* Inputs and buttons inside the filter sidebar are slimmer on desktop —
       mobile-sized 56px tap targets look bulky next to a 20rem sidebar. */
    .r2w-list-layout__filters .r2w-field__input,
    .r2w-list-layout__filters .r2w-field__select,
    .r2w-list-layout__filters .r2w-field__textarea {
        min-height: 2.5rem;
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }
    .r2w-list-layout__filters .r2w-field__label { font-size: var(--text-sm); }
    .r2w-list-layout__filters .r2w-field + .r2w-field { margin-top: var(--space-3); }
    .r2w-list-layout__filters .r2w-btn {
        min-height: 2.5rem;
        font-size: var(--text-sm);
    }
    .r2w-list-layout__filters .r2w-btn-clear {
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* Filter-summary block — sits below the form in the filter sidebar
   showing total count + filter chips + "showing X-Y of Z" line. */
.r2w-filter-summary {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

/* Small square clear/reset button — pairs with a primary form button. */
.r2w-btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap-target);
    height: var(--tap-target);
    flex-shrink: 0;
    background: var(--color-danger);
    color: #FFFFFF;
    border: 0;
    border-radius: var(--radius-md);
    text-decoration: none;
    cursor: pointer;
    transition: background 120ms ease, transform 60ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-btn-clear:hover { background: #991B1B; color: #FFFFFF; }
.r2w-btn-clear:active { transform: scale(0.95); }
.r2w-btn-clear:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.45); }
.r2w-btn-clear svg { width: 1.1rem; height: 1.1rem; }

/* Chip — small pill showing an active filter or tag */
.r2w-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0 var(--space-3);
}
.r2w-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.2rem var(--space-3);
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-brand-blue);
    border-radius: 999px;
    font-size: var(--text-sm);
    font-weight: 500;
}
.r2w-chip__label {
    color: var(--color-text-subtle);
    font-weight: 400;
}

/* Summary card — soft blue tint, used at the top of filtered result lists. */
.r2w-summary-card {
    background: linear-gradient(180deg, var(--color-primary-soft) 0%, var(--color-surface) 100%);
    border: 1px solid var(--color-brand-blue);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}
.r2w-summary-card__label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-primary-dark);
    font-weight: 700;
    margin: 0 0 var(--space-1);
}
.r2w-summary-card__amount {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--color-primary-darker);
    line-height: 1.05;
    margin: 0;
    letter-spacing: -0.01em;
}
.r2w-summary-card__meta {
    margin: var(--space-2) 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.r2w-summary-card .r2w-chip-group {
    margin: var(--space-3) 0 0;
}

/* Pagination row (used under result lists) */
.r2w-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-4);
}
.r2w-pagination__page-info {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.r2w-pagination__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 2.5rem;
    padding: 0 var(--space-4);
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #FFFFFF;
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 600;
    transition: background 120ms ease, transform 60ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-pagination__btn:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #FFFFFF; }
.r2w-pagination__btn:active { transform: scale(0.97); }

/* Floating page arrows — left/right FABs on mobile/tablet, hidden on desktop where the sidebar already shows pagination. */
.r2w-fab-pager {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--space-4));
    z-index: 80;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: var(--color-primary);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
    text-decoration: none;
    transition: background 120ms ease, transform 60ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-fab-pager:hover { background: var(--color-primary-dark); color: #FFFFFF; }
.r2w-fab-pager:active { transform: scale(0.93); }
.r2w-fab-pager:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.45), 0 4px 14px rgba(15, 23, 42, 0.25); }
.r2w-fab-pager--prev { left: var(--space-4); }
.r2w-fab-pager--next { right: var(--space-4); }
.r2w-fab-pager svg { width: 1.4rem; height: 1.4rem; }
@media (min-width: 900px) {
    .r2w-fab-pager { display: none; }
}
/* On mobile, the floating FAB arrows replace the inline pagination row
   inside .r2w-list-layout so they don't overlap. Inline row returns on desktop. */
@media (max-width: 899px) {
    .r2w-list-layout .r2w-pagination { display: none; }
}

/* ---- 10.5 Station card grid (Check-in stations) -------------- */
.r2w-station-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}
@media (min-width: 600px) {
    .r2w-station-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .r2w-station-grid { grid-template-columns: repeat(3, 1fr); }
}

.r2w-station-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    min-height: 3.5rem;
    overflow: hidden;
    transition: border-color 160ms ease, transform 80ms ease, box-shadow 160ms ease;
    -webkit-tap-highlight-color: transparent;
}
/* Subtle left accent stripe — anchors the card visually, brightens on hover. */
.r2w-station-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--color-border-strong);
    transition: background 160ms ease;
}
.r2w-station-card:hover {
    border-color: var(--color-primary);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.r2w-station-card:hover::before { background: var(--color-primary); }
.r2w-station-card:hover .r2w-station-card__chevron { transform: translateX(3px); color: var(--color-primary); }
.r2w-station-card:active { transform: translateY(0) scale(0.99); box-shadow: var(--shadow-sm); }
.r2w-station-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.r2w-station-card__icon {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary-soft) 0%, #BAE6FD 100%);
    border-radius: var(--radius-sm);
    color: var(--color-primary-dark);
    flex-shrink: 0;
}
.r2w-station-card__icon svg { width: 1.125rem; height: 1.125rem; }

.r2w-station-card__body { flex: 1; min-width: 0; }
.r2w-station-card__name {
    font-size: var(--text-base);
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.r2w-station-card__chevron {
    color: var(--color-text-subtle);
    flex-shrink: 0;
    transition: transform 160ms ease, color 160ms ease;
}
.r2w-station-card__chevron svg { width: 1.125rem; height: 1.125rem; }

/* ---- 10.7 Clothing checkout (Check-in clothing flow) --------- */
.r2w-cloth-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}
@media (min-width: 900px) {
    .r2w-cloth-layout {
        grid-template-columns: 1fr 22rem;
        align-items: start;
    }
}

.r2w-cloth-group { margin-bottom: var(--space-5); }
.r2w-cloth-group:last-child { margin-bottom: 0; }
.r2w-cloth-group__title {
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: 0 0 var(--space-3);
}

.r2w-cloth-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
}
@media (min-width: 600px) { .r2w-cloth-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .r2w-cloth-grid { grid-template-columns: repeat(4, 1fr); } }

.r2w-cloth-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    min-height: 4.5rem;
    transition: border-color 120ms, background 120ms, transform 60ms;
    -webkit-tap-highlight-color: transparent;
    font: inherit;
    color: var(--color-text);
}
.r2w-cloth-item:hover { border-color: var(--color-primary); }
.r2w-cloth-item:active { transform: scale(0.97); }
.r2w-cloth-item.has-count {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}
.r2w-cloth-item__name {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.15;
}
.r2w-cloth-item__value {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
/* Badge + remove button — matched size (1.5rem / 24px square) so corners look symmetric. */
.r2w-cloth-item__badge,
.r2w-cloth-item__remove {
    position: absolute;
    top: -8px;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    padding: 0;
    border: 2px solid var(--color-surface);
    border-radius: 999px;
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.18);
}
.r2w-cloth-item__badge { right: -8px; background: var(--color-primary); }
.r2w-cloth-item__remove {
    left: -8px;
    background: var(--color-danger);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 120ms ease, transform 60ms ease;
}
/* Invisible expanded hit area (~44×44 px) so the small visible circle is easy
   to tap on mobile. The pseudo-element belongs to the button, so clicks on it
   are routed to the button. */
.r2w-cloth-item__remove::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.75rem;
    height: 2.75rem;
    transform: translate(-50%, -50%);
}
.r2w-cloth-item__remove:hover { background: #991B1B; }
.r2w-cloth-item__remove:active { transform: scale(0.92); }
.r2w-cloth-item__remove:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.45); }
.r2w-cloth-item__remove:hover { background: #991B1B; }
.r2w-cloth-item__remove:active { transform: scale(0.92); }
.r2w-cloth-item__remove:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.45); }

/* Cart panel */
.r2w-cart {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
}
@media (min-width: 900px) {
    .r2w-cart {
        position: sticky;
        top: calc(var(--header-height) + var(--space-4));
    }
}
.r2w-cart__title {
    font-size: var(--text-base);
    font-weight: 700;
    margin: 0 0 var(--space-2);
}
.r2w-cart__hint {
    font-size: 0.85rem;
    color: var(--color-text-subtle);
    margin: 0 0 var(--space-3);
}
.r2w-cart__items { margin-bottom: var(--space-3); }
.r2w-cart__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.r2w-cart__row:hover { background: var(--color-bg); }
.r2w-cart__row-name { font-size: var(--text-sm); font-weight: 500; }
.r2w-cart__row-meta { font-size: var(--text-sm); color: var(--color-text-muted); }
.r2w-cart__empty {
    padding: var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}
.r2w-cart__total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-3) 0;
    border-top: 2px solid var(--color-border);
}
.r2w-cart__total-label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 500; }
.r2w-cart__total-amount { font-size: var(--text-2xl); font-weight: 800; color: var(--color-primary-darker); }
.r2w-cart__checkout {
    margin-top: var(--space-4);
}

/* ---- 10.75 Floating action button (scroll-jump) -------------- */
.r2w-fab-scroll {
    position: fixed;
    right: var(--space-4);
    top: calc(var(--header-height) + var(--space-3));   /* just below topbar */
    z-index: 90;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 999px;
    background: var(--color-primary);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 160ms ease, transform 80ms ease, opacity 200ms ease;
}
.r2w-fab-scroll:hover { background: var(--color-primary-dark); }
.r2w-fab-scroll:active { transform: scale(0.93); }
.r2w-fab-scroll:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.45), 0 4px 14px rgba(15, 23, 42, 0.25); }
.r2w-fab-scroll svg { width: 1.25rem; height: 1.25rem; }
.r2w-fab-scroll[hidden] { display: none; }
/* Cart is sticky-visible on desktop, so the FAB is mobile-only. */
@media (min-width: 900px) { .r2w-fab-scroll { display: none !important; } }

/* ---- 10.8 QR scanner container ------------------------------ */
.r2w-scanner {
    max-width: 420px;
    margin: var(--space-3) auto 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    aspect-ratio: 1 / 1;       /* square viewport regardless of camera native ratio */
}
.r2w-scanner > div { border: 0 !important; }
.r2w-scanner video,
.r2w-scanner canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}
.r2w-scanner img { display: inline-block !important; }
/* Waitlist filter tabs (Main + per-station icons) */
.r2w-wl-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-1) 0;
}
.r2w-wl-tab {
    /* iOS/Safari aggressively re-styles <button> with native UI when
       appearance isn't reset — that's what was killing the rounded
       shape, border, and active-fill on mobile. */
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 2.5rem;
    padding: 0 var(--space-3);
    white-space: nowrap;
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border);
    border-radius: 999px;
    font-weight: 700;
    font-size: var(--text-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    -webkit-tap-highlight-color: transparent;
}
.r2w-wl-tab--icon {
    width: 2.5rem;
    padding: 0;
}
.r2w-wl-tab.is-active {
    background: var(--color-primary);
    color: #FFFFFF;
    border-color: var(--color-primary);
}

/* Dedicated action row for the consulting form. Mark-complete is the
   visual primary, Next is secondary blue, Back is a quiet underline.
   Autosave status lives on its own line so it doesn't compete with the
   primary action.

   Layout:
     • Mobile  — stacked, full-width, primary action on top.
     • Tablet+ — primary action on the right, Back on the left, status above. */
.r2w-consulting-actions {
    margin-top: var(--space-5);
    max-width: 52rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
}
.r2w-consulting-actions .r2w-btn { width: 100%; }
.r2w-consulting-actions__complete {
    background: var(--color-success, #10B981);
    color: #FFFFFF;
    border: 2px solid var(--color-success, #10B981);
    min-height: 3.25rem;
    font-size: var(--text-lg);
    font-weight: 800;
    letter-spacing: 0.01em;
}
.r2w-consulting-actions__complete:hover { background: #059669; border-color: #059669; }
.r2w-consulting-actions__next { min-height: 3.25rem; font-size: var(--text-lg); font-weight: 700; }
.r2w-consulting-actions__back {
    /* Quiet by default — back-tracking is a secondary action. */
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
    text-decoration: underline;
}
.r2w-consulting-actions__back:hover { color: var(--color-text); background: transparent; }
.r2w-consulting-actions__status {
    margin: var(--space-2) 0 0;
    text-align: center;
    font-size: var(--text-sm);
}
@media (min-width: 600px) {
    .r2w-consulting-actions {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "back  status   primary"
            ".     .        .";
        align-items: center;
    }
    .r2w-consulting-actions__back     { grid-area: back;    width: auto; min-width: 7rem; justify-self: start; }
    .r2w-consulting-actions__status   { grid-area: status;  margin: 0; text-align: right; padding-right: var(--space-3); }
    .r2w-consulting-actions__next,
    .r2w-consulting-actions__complete { grid-area: primary; width: auto; min-width: 12rem; justify-self: end; }
}

/* Reports hub page footer — Foqas logo bottom-right. */
.r2w-reports-footer {
    margin-top: var(--space-6);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

/* Print stylesheet for the reports hub — used when the user clicks
   "Download PDF" (which triggers window.print() and offers Save-as-PDF).
   Hides app chrome (topbar, drawer, bottom-nav, action buttons, page-load
   overlays) and gives the reports a clean page-friendly layout. */
.r2w-no-print { /* nothing on screen — only matters in print */ }
@media print {
    /* Strip all the app chrome */
    .r2w-topbar,
    .r2w-bottom-nav,
    .r2w-drawer,
    .r2w-drawer-backdrop,
    .r2w-progress-bar,
    #r2w-page-loading-overlay,
    .r2w-no-print {
        display: none !important;
    }
    body { background: white !important; }
    .r2w-main {
        padding: 0 !important;
    }
    .r2w-main__inner {
        max-width: none !important;
    }
    /* Card surfaces look cleaner without heavy shadow on paper */
    .r2w-card {
        box-shadow: none !important;
        border: 1px solid #d4d4d4 !important;
        page-break-inside: avoid;
    }
    section { page-break-inside: avoid; }
    /* Reset body color in case dark theme */
    body, p, dl, dd, dt, span, div { color: black !important; }
    a { color: #0c4f7c !important; text-decoration: none !important; }
}

/* Page-loading overlay for slow routes (reports hub etc.). Hidden by
   default; body.r2w-page-loading reveals it. The new page replaces the
   body on navigation so it auto-clears. */
#r2w-page-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}
body.r2w-page-loading #r2w-page-loading-overlay { display: flex; }
.r2w-page-loading-card {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--color-surface);
    padding: var(--space-3) var(--space-5);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    font-weight: 700;
    color: var(--color-text);
}
.r2w-page-loading-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: r2w-spin 0.8s linear infinite;
}
@keyframes r2w-spin { to { transform: rotate(360deg); } }

/* Multi-step stepper used by the consulting form. Numbered circle nodes
   connected by lines. is-current = brand blue, is-done = success green,
   is-todo = neutral grey. Labels are visible on desktop, hidden on mobile
   (only the circle + connector remains for compactness). */
.r2w-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: var(--space-4);
    margin-bottom: var(--space-2);
    padding: 0 var(--space-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Hide the scrollbar visually — touch-pan still works on mobile. */
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE/old Edge */
}
.r2w-stepper::-webkit-scrollbar { display: none; }
.r2w-stepper__node {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--color-text-muted);
    flex-shrink: 0;
    min-width: 2.5rem;
    -webkit-tap-highlight-color: transparent;
}
.r2w-stepper__num {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 3px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.r2w-stepper__label {
    margin-top: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    color: inherit;
    max-width: 6rem;
    line-height: 1.2;
}
.r2w-stepper__node.is-current .r2w-stepper__num {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #FFFFFF;
}
.r2w-stepper__node.is-current { color: var(--color-primary); }
.r2w-stepper__node.is-done .r2w-stepper__num {
    background: var(--color-success, #10B981);
    border-color: var(--color-success, #10B981);
    color: #FFFFFF;
}
.r2w-stepper__node.is-done { color: var(--color-success, #047857); }
.r2w-stepper__connector {
    flex: 1 1 auto;
    height: 3px;
    min-width: 1.25rem;
    background: var(--color-border);
    align-self: flex-start;
    margin-top: 1.1rem;
    border-radius: 2px;
}
.r2w-stepper__connector.is-done { background: var(--color-success, #10B981); }
@media (max-width: 600px) {
    .r2w-stepper__label { display: none; }
}

/* Group of related fields inside a consulting step — gives every section
   its own card with a soft heading. Helps break up the long form. */
.r2w-form-section {
    margin-top: var(--space-4);
}
.r2w-form-section__title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 var(--space-1);
}
.r2w-form-section__subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-3);
}

/* Tap-target wrappers for radio + checkbox lists in the consulting form.
   Make the whole card tappable, not just the small native input. */
.r2w-choice-list { display: grid; gap: var(--space-2); }
.r2w-choice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.r2w-choice:hover { border-color: var(--color-primary); }
.r2w-choice input[type="radio"],
.r2w-choice input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}
.r2w-choice:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}
.r2w-choice__text {
    flex: 1;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--color-text);
}

/* "Already served at" badges on the Main waitlist row — small soft
   chips showing which stations a neighbour has already attended today. */
.r2w-served-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.r2w-served-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--color-success-soft, #ECFDF5);
    color: var(--color-success, #047857);
    border-radius: 999px;
}

/* QR viewfinder corner brackets — drawn as a sibling overlay so the
   html5-qrcode library's DOM mutations inside #reader don't wipe them.
   The wrap takes on the scanner's square sizing so brackets pin to the
   actual camera viewport, not the surrounding card. */
.r2w-scanner-wrap {
    position: relative;
    max-width: 420px;
    margin: var(--space-3) auto 0;
    aspect-ratio: 1 / 1;
}
.r2w-scanner-wrap .r2w-scanner {
    /* When wrapped, the wrap handles the size constraint. */
    max-width: none;
    margin: 0;
    width: 100%;
    height: 100%;
}
.r2w-scanner-brackets {
    position: absolute;
    inset: 8%;
    pointer-events: none;
}
.r2w-scanner-bracket {
    position: absolute;
    width: 2.5rem;
    height: 2.5rem;
    border: 0 solid rgba(255,255,255,0.95);
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.5));
}
.r2w-scanner-bracket--tl { top: 0;    left: 0;    border-top-width: 4px; border-left-width: 4px;   border-top-left-radius: 8px; }
.r2w-scanner-bracket--tr { top: 0;    right: 0;   border-top-width: 4px; border-right-width: 4px;  border-top-right-radius: 8px; }
.r2w-scanner-bracket--bl { bottom: 0; left: 0;    border-bottom-width: 4px; border-left-width: 4px;   border-bottom-left-radius: 8px; }
.r2w-scanner-bracket--br { bottom: 0; right: 0;   border-bottom-width: 4px; border-right-width: 4px;  border-bottom-right-radius: 8px; }

/* Friendly fallback shown when camera permission is blocked / unavailable. */
.r2w-camera-blocked {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    height: 100%;
    padding: var(--space-5) var(--space-4);
    text-align: center;
    color: #FFFFFF;
    background: var(--color-text);     /* dark backdrop, matches the camera viewport */
}
.r2w-camera-blocked p { margin: 0; color: #FFFFFF; }

.r2w-summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-3);
}
.r2w-summary-row:last-of-type { border-bottom: 0; }
.r2w-summary-row__name { font-weight: 600; color: var(--color-text); }
.r2w-summary-row__count { color: var(--color-text-muted); font-size: var(--text-sm); margin-left: var(--space-2); }
.r2w-summary-row__amount { color: var(--color-text); font-weight: 500; flex-shrink: 0; }

/* ---- 11. Visually-hidden (a11y) ------------------------------- */
.r2w-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;
}
