/* ============================================================
   Fraser Family Foundation — Design tokens
   Import order: colors → typography → spacing → tartan.
   All component styles below consume these CSS variables.
   ============================================================ */
@import url('tokens/colors.css');
@import url('tokens/typography.css');
@import url('tokens/spacing.css');
@import url('tokens/tartan.css');

/* Global font stack with wide Unicode coverage */
body {
    font-family: var(--font-sans);
    background-color: var(--surface-page);
    color: var(--text-body);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
}

/* Skip Navigation Links - hidden until focused for accessibility */
.skip-navigation {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3000; /* above header */
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.skip-link:focus,
.skip-link:active {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    padding: var(--space-2) var(--space-4);
    background: var(--accent-primary);
    color: #fff !important;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
    outline: 2px solid #fff;
    outline-offset: 0;
}

/* Existing styles */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--fff-success);
}

.invalid {
    outline: 1px solid var(--fff-danger);
}

.validation-message {
    color: var(--fff-danger);
}

#blazor-error-ui {
    background: var(--surface-card);
    border: 1px solid var(--fff-danger);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-raised);
    display: none;
    left: 50%;
    padding: var(--space-6);
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: var(--space-3);
        top: var(--space-2);
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAi IGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--surface-page);
    color: var(--text-body);
}

.loading-icon {
    width: 96px;
    height: 96px;
    margin-bottom: 2rem;
    filter: brightness(0) saturate(100%) invert(27%) sepia(94%) saturate(7471%) hue-rotate(358deg) brightness(95%) contrast(118%);
}

.loading-spinner {
    margin-bottom: 2rem;
}

.loading-text {
    font-size: var(--fs-lead);
    font-weight: var(--fw-medium);
}

code {
    color: var(--fff-crimson);
    font-family: var(--font-mono);
}

/* Layout Styles */
.page-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-header);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    color: var(--text-body) !important;
    text-decoration: none;
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
}

.navbar-brand:hover {
    color: var(--accent-active) !important;
}

/* Brand lockup: logo mark + two-line name/subtitle */
.fff-brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}

.fff-brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 auto;
    /* Recolor the black SVG mark to Fraser forest green */
    filter: brightness(0) saturate(100%) invert(24%) sepia(28%) saturate(1533%) hue-rotate(114deg) brightness(94%) contrast(97%);
}

.fff-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.fff-brand-name {
    font-size: var(--fs-body);
    font-weight: var(--fw-bold);
    color: var(--accent-primary);
}

.fff-brand-sub {
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}

.navbar-brand:hover .fff-brand-name {
    color: var(--accent-active);
}

.main-content {
    flex: 1;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-sunken);
    border-right: 1px solid var(--border-hairline);
    min-height: calc(100vh - var(--header-height));
}

.sidebar-content {
    padding: var(--space-4);
}

.fff-nav-heading {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 var(--space-2);
    padding: 0 var(--space-2);
}

.fff-nav-rule {
    margin: var(--space-4) 0;
    opacity: 0.85;
}

.sidebar .nav-link {
    color: var(--text-body);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-1);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.sidebar .nav-link:hover {
    background-color: var(--border-hairline);
    color: var(--text-heading);
}

.sidebar .nav-link.active {
    background-color: var(--accent-active);
    color: white;
}

.sidebar .nav-link i {
    margin-right: var(--space-3);
    width: 1rem;
}

.content-area {
    flex: 1;
    padding: var(--space-4);
    overflow-x: hidden;
    background-color: var(--surface-page);
}

.unauthenticated-content {
    width: 100%;
    min-height: calc(100vh - var(--header-height));
    background-color: var(--surface-page);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* Mobile Navigation */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--fs-h3);
    padding: var(--space-2);
    cursor: pointer;
    color: var(--text-body);
    position: relative;
    z-index: 2001; /* Above sidebar */
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}

.mobile-nav-overlay.show {
    display: block;
}

/* Content Area Improvements */
.content-area {
    flex: 1;
    padding: var(--space-4);
    overflow-x: hidden;
    background-color: var(--surface-page);
}

@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: calc(-1 * var(--sidebar-width));
        width: var(--sidebar-width);
        height: 100vh;
        z-index: 2000;
        transition: left var(--dur-base) var(--ease-standard);
        background: var(--surface-sunken);
        border-right: 1px solid var(--border-hairline);
        padding-top: var(--header-height); /* Account for header height */
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .content-area {
        width: 100%;
        padding: 0.75rem;
    }
    
    /* Ensure header content stacks properly on mobile */
    .top-header .d-flex {
        flex-wrap: wrap;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    /* Responsive Tables */
    .table-responsive-stack {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive-stack .table {
        margin-bottom: 0;
    }
    
    /* Card-based mobile layout for complex tables */
    .mobile-card-view {
        display: none;
    }
    
    .mobile-card-view .card {
        margin-bottom: var(--space-4);
        border: 1px solid var(--border-card);
    }
    
    .mobile-card-view .card-body {
        padding: 0.75rem;
    }
    
    /* Show card view and hide table on small screens */
    .table-responsive-mobile {
        display: block;
    }
    
    .mobile-card-view {
        display: block;
    }
    
    .table-responsive-mobile {
        display: none;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .header-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.25rem;
    }
    
    .top-header .py-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .content-area {
        padding: 0.5rem;
    }
    
    /* Stack buttons vertically on very small screens */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .btn-group-mobile .btn {
        width: 100%;
        margin: 0;
    }
}

/* ============================================================
   Brand utilities & Bootstrap overrides
   On-brand primitives layered over Bootstrap 5, driven by tokens.
   ============================================================ */

/* --- Headings ----------------------------------------------------- */
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    color: var(--text-heading);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
}

.text-muted-brand {
    color: var(--text-muted) !important;
}

/* --- Signature gradient surfaces ---------------------------------- */
.fff-gradient-bg {
    background: var(--fff-gradient);
    color: #fff;
}

.fff-gradient-text {
    background: var(--fff-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--accent-primary); /* fallback where clip unsupported */
}

/* Hero / auth surface: tartan texture behind the brand gradient */
.fff-hero {
    position: relative;
    background: var(--fff-gradient);
    color: #fff;
    border-radius: var(--radius-xl);
    overflow: hidden;
    isolation: isolate;
}

.fff-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--tartan-field);
    opacity: 0.15;
    z-index: -1;
}

/* --- Buttons ------------------------------------------------------ */
.btn {
    border-radius: var(--radius-lg);
    font-weight: var(--fw-medium);
    transition: transform var(--dur-fast) var(--ease-standard),
                box-shadow var(--dur-fast) var(--ease-standard),
                background-color var(--dur-fast) var(--ease-standard),
                border-color var(--dur-fast) var(--ease-standard);
}

.btn-primary {
    background: var(--fff-gradient);
    border: none;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--fff-gradient-hover);
    box-shadow: var(--shadow-btn-hover);
    transform: var(--lift);
}

.btn-primary:active {
    transform: none;
}

.btn-outline-primary {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.btn-secondary {
    background-color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: var(--fff-navy-700);
    border-color: var(--fff-navy-700);
}

.btn-danger {
    background-color: var(--fff-danger);
    border-color: var(--fff-danger);
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: var(--fff-danger-deep);
    border-color: var(--fff-danger-deep);
}

/* --- Cards -------------------------------------------------------- */
.card {
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    background: var(--surface-card);
}

.card-title {
    color: var(--text-heading);
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
}

/* Interactive card that lifts on hover */
.fff-card-interactive {
    transition: transform var(--dur-fast) var(--ease-standard),
                box-shadow var(--dur-fast) var(--ease-standard);
    cursor: pointer;
}

.fff-card-interactive:hover,
.fff-card-interactive:focus-within {
    transform: var(--lift);
    box-shadow: var(--shadow-raised);
}

/* --- Badges ------------------------------------------------------- */
.badge {
    border-radius: var(--radius-pill);
    font-weight: var(--fw-medium);
    letter-spacing: var(--ls-wide);
}

.badge.bg-success { background-color: var(--fff-success) !important; }
.badge.bg-primary { background-color: var(--accent-primary) !important; }
.badge.bg-secondary { background-color: var(--accent-secondary) !important; }
.badge.bg-danger { background-color: var(--fff-danger) !important; }

.fff-badge-soft-success {
    background-color: var(--fff-success-bg);
    color: var(--fff-success-ink);
}

.fff-badge-soft-info {
    background-color: var(--fff-info-bg);
    color: var(--fff-info);
}

.fff-badge-soft-warning {
    background-color: var(--fff-warning-bg);
    color: var(--fff-warning);
}

.fff-badge-soft-danger {
    background-color: var(--fff-danger-bg);
    color: var(--fff-danger-deep);
}

/* --- Forms -------------------------------------------------------- */
.form-control,
.form-select {
    border-radius: var(--radius-md);
    border-color: var(--border-card);
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
.form-check-input:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 0.25rem rgba(15, 94, 58, 0.25);
}

.form-check-input:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Visible keyboard focus for interactive shell elements */
a:focus-visible,
.nav-link:focus-visible,
.navbar-brand:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* --- Alerts ------------------------------------------------------- */
.alert {
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--fff-success-bg);
    color: var(--fff-success-ink);
    border-color: var(--fff-success);
}

.alert-danger {
    background-color: var(--fff-danger-bg);
    color: var(--fff-danger-deep);
    border-color: var(--fff-danger);
}

.alert-warning {
    background-color: var(--fff-warning-bg);
    color: var(--fff-warning);
    border-color: var(--fff-warning);
}

.alert-info {
    background-color: var(--fff-info-bg);
    color: var(--fff-info);
    border-color: var(--fff-info);
}

/* --- Tables ------------------------------------------------------- */
.table thead th {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-card);
}

.table tbody td {
    color: var(--text-body);
    vertical-align: middle;
}

/* --- Links -------------------------------------------------------- */
a {
    color: var(--accent-secondary);
    text-decoration-color: color-mix(in srgb, var(--accent-secondary) 40%, transparent);
}

a:hover {
    color: var(--fff-navy-700);
}

/* ============================================================
   Brand primitives (PageHeader, BrandCard, StatCard)
   ============================================================ */

/* --- PageHeader --------------------------------------------------- */
.fff-page-header {
    margin-bottom: var(--space-5);
}

.fff-page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.fff-page-header-titles {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.fff-page-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    border-radius: var(--radius-lg);
    background: var(--fff-gradient);
    color: #fff;
    font-size: var(--fs-h3);
}

.fff-page-title {
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    margin: 0;
    line-height: var(--lh-tight);
}

.fff-page-subtitle {
    margin: var(--space-1) 0 0;
    font-size: var(--fs-body);
}

.fff-page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.fff-page-header-rule {
    margin-top: var(--space-4);
    margin-bottom: 0;
    opacity: 0.9;
}

/* --- BrandCard ---------------------------------------------------- */
.fff-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    background: var(--fff-success-bg);
    color: var(--accent-primary);
    font-size: var(--fs-h3);
}

/* --- StatCard ----------------------------------------------------- */
.min-w-0 {
    min-width: 0;
}

.fff-stat-card .fff-stat-value {
    font-size: var(--fs-display);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    line-height: var(--lh-tight);
}

.fff-stat-card .fff-stat-label {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}

.fff-stat-card .fff-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-lg);
    font-size: var(--fs-h2);
    flex: 0 0 auto;
}

.fff-stat-icon.tone-primary { background: var(--fff-success-bg); color: var(--accent-primary); }
.fff-stat-icon.tone-secondary { background: var(--fff-info-bg); color: var(--accent-secondary); }
.fff-stat-icon.tone-accent { background: rgba(102, 126, 234, 0.15); color: var(--accent-active); }
.fff-stat-icon.tone-warning { background: var(--fff-warning-bg); color: var(--fff-warning); }
.fff-stat-icon.tone-danger { background: var(--fff-danger-bg); color: var(--fff-danger); }

.fff-stat-trend {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
}

.fff-stat-trend.trend-up { color: var(--fff-success); }
.fff-stat-trend.trend-down { color: var(--fff-danger); }

/* --- Contact dashboard: hero ------------------------------------- */
.fff-contact-hero {
    background: var(--fff-gradient);
    border-radius: var(--radius-xl);
    color: #fff;
    padding: var(--space-5) var(--space-5);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.fff-contact-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--tartan-field, none);
    background-size: 44px 44px;
    opacity: 0.10;
    pointer-events: none;
}

.fff-contact-hero-body {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.fff-contact-avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.35);
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
}

.fff-contact-identity {
    min-width: 0;
    flex: 1 1 260px;
}

.fff-contact-name-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.fff-contact-name {
    margin: 0;
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    color: #fff;
}

.fff-contact-subtitle {
    margin-top: var(--space-1);
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    font-size: var(--fs-sm);
    color: rgba(255, 255, 255, 0.85);
}

.fff-contact-nickname {
    font-style: italic;
}

.fff-contact-facts {
    margin-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.92);
}

.fff-contact-fact {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}

a.fff-contact-fact:hover,
a.fff-contact-fact:focus {
    color: #fff;
    text-decoration: underline;
}

.fff-contact-fact i {
    opacity: 0.85;
}

/* --- Contact dashboard: giving history --------------------------- */
.fff-giving-total {
    font-size: var(--fs-h3);
    font-weight: var(--fw-bold);
    color: var(--fff-green);
}

.fff-gift-list {
    max-height: 22rem;
    overflow-y: auto;
}

.fff-gift-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-hairline);
}

.fff-gift-row:first-child {
    border-top: none;
}

.fff-gift-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fff-gift-date {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.fff-gift-rel {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.fff-gift-amount {
    flex: 0 0 auto;
    font-weight: var(--fw-bold);
    color: var(--fff-green);
    font-variant-numeric: tabular-nums;
}

/* --- Contact dashboard: affinity meters -------------------------- */
.fff-affinity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.fff-affinity-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.fff-affinity-type {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.fff-affinity-score {
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    font-variant-numeric: tabular-nums;
}

.fff-affinity-max {
    color: var(--text-muted);
    font-weight: var(--fw-normal);
    font-size: var(--fs-sm);
}

.fff-affinity-meter {
    height: 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
}

.fff-affinity-meter .progress-bar {
    border-radius: var(--radius-pill);
}

.fff-affinity-desc {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-muted);
}

/* --- Contact dashboard: contact methods & social ----------------- */
.fff-contact-methods,
.fff-social-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.fff-method-row,
.fff-social-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.fff-method-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    background: var(--fff-success-bg);
    color: var(--accent-primary);
    font-size: var(--fs-h3);
}

.fff-method-body {
    min-width: 0;
    word-break: break-word;
}

.fff-method-label {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--ls-wide);
}

/* --- Contact dashboard: shared ----------------------------------- */
.fff-section-heading {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-h3);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
}

.fff-section-heading i {
    color: var(--accent-primary);
}

.fff-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-3);
    color: var(--text-muted);
    text-align: center;
}

.fff-empty i {
    font-size: var(--fs-display);
    opacity: 0.45;
}

.fff-empty-icon {
    font-size: var(--fs-display);
    opacity: 0.45;
}

/* --- Contacts list: filter toolbar ------------------------------- */
.fff-contacts-toolbar .form-label {
    font-weight: var(--fw-medium);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}

/* --- Contacts list: card grid ------------------------------------ */
.fff-contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: var(--space-4);
}

/* Invisible trigger element observed for infinite scroll. */
.fff-scroll-sentinel {
    width: 100%;
    height: 1px;
}

.fff-contact-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-card, #fff);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.fff-contact-card:hover,
.fff-contact-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover, var(--shadow-card));
    border-color: var(--accent-primary);
    outline: none;
}

.fff-contact-card:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.fff-contact-card--inactive {
    opacity: 0.72;
    background: var(--surface-sunken, #f6f6f6);
}

.fff-contact-card__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.fff-contact-card__avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-pill);
    background: var(--fff-gradient);
    color: #fff;
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
}

.fff-contact-card__identity {
    min-width: 0;
    flex: 1 1 auto;
}

.fff-contact-card__name {
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    line-height: var(--lh-tight);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fff-contact-card__nickname {
    font-size: var(--fs-sm);
    font-style: italic;
    color: var(--text-muted);
}

.fff-contact-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-hairline);
    border-bottom: 1px solid var(--border-hairline);
}

.fff-contact-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    min-width: 0;
}

.fff-contact-metric__value {
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.fff-contact-metric__label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: var(--ls-wide);
    color: var(--text-muted);
}

.fff-contact-contactinfo {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.fff-contact-line {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    font-size: var(--fs-sm);
    color: var(--text-body, inherit);
}

.fff-contact-line i {
    flex: 0 0 auto;
    color: var(--accent-primary);
}

.fff-contact-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-2);
}

/* --- Reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    .btn-primary:hover,
    .btn-primary:focus,
    .fff-card-interactive:hover,
    .fff-card-interactive:focus-within {
        transform: none;
    }
}
