/* ==========================================================================
   RVH Liver Support Group - Patient Portal
   Design System & Clinical UI Stylesheet
   Strictly Zero-CDN • Pure Vanilla CSS • WCAG 2.1 AA/AAA High Contrast
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & Color System
   -------------------------------------------------------------------------- */
:root {
    /* Bootstrap 5 Theme Harmonization (Zero-CDN) */
    --bs-primary: #0284c7;
    --bs-primary-rgb: 2, 132, 199;
    --bs-secondary: #475569;
    --bs-secondary-rgb: 71, 85, 105;
    --bs-success: #16a34a;
    --bs-success-rgb: 22, 163, 74;
    --bs-danger: #dc2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-warning: #d97706;
    --bs-warning-rgb: 217, 119, 6;
    --bs-info: #0284c7;
    --bs-info-rgb: 2, 132, 199;
    --bs-dark: #0f172a;
    --bs-dark-rgb: 15, 23, 42;
    --bs-body-color: #0f172a;
    --bs-body-bg: #f8fafc;
    --bs-link-color: #0284c7;
    --bs-link-hover-color: #0369a1;
    --bs-border-color: #cbd5e1;
    --bs-border-radius: 8px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 12px;

    /* Brand & Clinical Navy */
    --color-navy: #0b2545;
    --color-navy-dark: #07192f;
    --color-navy-light: #133a6b;

    /* Primary Action Blue */
    --color-primary: #0284c7;
    --color-primary-hover: #0369a1;
    --color-primary-dark: #075985;
    --color-primary-light: #e0f2fe;
    --color-primary-border: #bae6fd;

    /* Success Green */
    --color-success: #16a34a;
    --color-success-dark: #15803d;
    --color-success-text: #14532d;
    --color-success-bg: #f0fdf4;
    --color-success-border: #bbf7d0;

    /* Amber Warning */
    --color-warning: #d97706;
    --color-warning-dark: #b45309;
    --color-warning-text: #78350f;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fde68a;

    /* Crimson Danger */
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-danger-text: #7f1d1d;
    --color-danger-bg: #fef2f2;
    --color-danger-border: #fecaca;

    /* Restricted Masking Purple */
    --color-restricted: #7e22ce;
    --color-restricted-dark: #6b21a8;
    --color-restricted-text: #581c87;
    --color-restricted-bg: #faf5ff;
    --color-restricted-border: #e9d5ff;

    /* Neutral Surfaces & Backgrounds */
    --color-surface: #ffffff;
    --color-bg: #f8fafc;
    --color-surface-subtle: #f1f5f9;
    --color-surface-hover: #f1f5f9;

    /* High-Contrast Typography Tokens */
    --color-text: #0f172a;        /* 17.5:1 on white (AAA) */
    --color-text-muted: #475569;  /* 7.0:1 on white (AAA) */
    --color-text-light: #64748b;
    --color-text-inverse: #ffffff;

    /* Borders & Dividers */
    --color-border: #cbd5e1;
    --color-border-light: #e2e8f0;
    --color-border-focus: #0284c7;

    /* Radii */
    --radius-xs: 3px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    --shadow-focus: 0 0 0 3px rgba(2, 132, 199, 0.35);

    /* Spacing & Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-base: 0.2s ease-in-out;

    /* Monospace Font Stack & Legacy Token Aliases */
    --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --font-mono: var(--font-family-mono);
    --primary: var(--color-primary);
    --text-muted: var(--color-text-muted);
    --success: var(--color-success);
    --color-text-emphasis: var(--color-navy);
    --color-bg-secondary: var(--color-surface-subtle);
}

/* --------------------------------------------------------------------------
   2. Reset & Base Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-weight: 400;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    max-width: 100vw;
}

/* Accessible Focus States (NHS Digital & WCAG 2.2 AA Standard) */
:focus-visible {
    outline: 3px solid #ffdd00 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #0b0c0c !important;
}

/* WCAG 2.2 SC 2.4.11 - Focus Not Obscured Guard (Sticky & Bottom Navigation Safe Margin) */
input, select, textarea, button, a, [tabindex], summary {
    scroll-margin-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    scroll-margin-top: 80px;
}

/* WCAG 2.2 SC 2.5.8 - Target Size (Minimum 24px x 24px bounding box, 44px+ for mobile controls) */
button, input[type="button"], input[type="submit"], input[type="reset"], .btn, .nav-link, .nav-bottom-item, .tab-btn {
    min-height: 40px;
    min-width: 40px;
}

.table-action-btn, .btn-xs, .btn-sm, input[type="checkbox"], input[type="radio"] {
    min-height: 24px;
    min-width: 24px;
}

/* Accessible Skip Link */
.skip-link {
    position: absolute;
    top: -999px;
    left: 16px;
    z-index: 10000;
    padding: 12px 20px;
    background: var(--color-navy);
    color: var(--color-surface);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-primary);
    box-shadow: var(--shadow-lg);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 16px;
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-navy);
    font-weight: 700;
    line-height: 1.25;
}

p {
    margin-bottom: 0.5rem;
}

p:last-child {
    margin-bottom: 0;
}

code, kbd, samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875em;
    background-color: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    color: var(--color-navy);
}

/* --------------------------------------------------------------------------
   3. Header, Navigation & Brand
   -------------------------------------------------------------------------- */
.navbar {
    background-color: var(--color-navy);
    color: var(--color-surface);
    border-bottom: 3px solid var(--color-primary);
    padding: 0 24px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    gap: 16px;
    flex-wrap: nowrap;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-surface);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.navbar-brand:hover,
.navbar-brand:focus-visible {
    color: var(--color-primary-light);
}

.navbar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--color-primary), #0369a1);
    border-radius: var(--radius-md);
    color: var(--color-surface);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.navbar-brand-text {
    display: flex;
    flex-direction: column;
}

.navbar-brand-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.15;
    color: #ffffff;
}

.navbar-brand-subtitle {
    font-size: 0.72rem;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

@media (max-width: 1200px) {
    .navbar-brand-subtitle {
        display: none;
    }
}

.navbar-desktop {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    justify-content: flex-start;
    margin-left: 18px;
    min-width: 0;
}

.navbar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    list-style: none;
    align-items: center;
    margin: 0;
    padding: 0;
}

.navbar-nav a.nav-link,
.navbar-nav button.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
    background: transparent;
    border: none;
    text-decoration: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.navbar-nav a.nav-link:hover,
.navbar-nav button.nav-link:hover,
.nav-dropdown.is-open > .nav-link {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.12);
}

.navbar-nav a.nav-link.active,
.navbar-nav button.nav-link.active,
.navbar-nav .nav-link.active {
    color: #ffffff !important;
    background-color: rgba(2, 132, 199, 0.35);
    border: 1px solid rgba(2, 132, 199, 0.6);
}

.navbar-nav a.nav-link.active:hover,
.navbar-nav button.nav-link.active:hover,
.navbar-nav .nav-link.active:hover {
    color: #ffffff !important;
    background-color: rgba(2, 132, 199, 0.5);
}

/* Dropdown Menus */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-chevron {
    transition: transform var(--transition-fast);
    opacity: 0.7;
}

.nav-dropdown.is-open .nav-dropdown-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 240px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    padding: 6px 0;
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.55), 0 8px 12px -6px rgba(0, 0, 0, 0.35);
    z-index: 1050;
    display: none;
}

.nav-dropdown.is-open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu.menu-right {
    left: auto;
    right: 0;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    width: 100%;
    white-space: nowrap;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus-visible {
    background: rgba(2, 132, 199, 0.25);
    color: #ffffff;
}

.nav-dropdown-item.active {
    color: #38bdf8;
    font-weight: 600;
    background: rgba(2, 132, 199, 0.15);
}

.nav-dropdown-item.nav-dropdown-danger {
    color: #f87171;
}

.nav-dropdown-item.nav-dropdown-danger:hover {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.nav-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 6px 0;
}

/* User Profile Pill & Dropdown */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-pill);
    color: #ffffff;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.user-profile-btn:hover,
.nav-dropdown.is-open .user-profile-btn {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
}

.user-display-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #f1f5f9;
}

/* Mobile Toggle */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: #ffffff;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition-fast);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Off-Canvas Drawer */
body.drawer-open {
    overflow: hidden;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 37, 69, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.25s ease-out;
}

.drawer-backdrop.is-active {
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 310px;
    max-width: 85vw;
    background: #0b2545;
    color: #ffffff;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.45);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}

.mobile-drawer.is-active {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.drawer-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.drawer-user-card {
    padding: 14px 18px;
    background: rgba(2, 132, 199, 0.18);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.drawer-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #ffffff;
}

.drawer-content {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.drawer-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 14px 12px 6px;
}

.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    min-height: 48px;
}

.drawer-nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.drawer-nav-item.active {
    color: #ffffff;
    background: rgba(2, 132, 199, 0.35);
    border-left: 4px solid #38bdf8;
}

.drawer-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fca5a5;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
    min-height: 48px;
    transition: all var(--transition-fast);
}

.drawer-logout-btn:hover {
    background: rgba(220, 38, 38, 0.25);
    color: #ffffff;
}

.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-pill);
    background-color: rgba(2, 132, 199, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(2, 132, 199, 0.4);
}

.user-role-badge.role-clinician {
    background-color: rgba(22, 163, 74, 0.2);
    color: #86efac;
    border-color: rgba(22, 163, 74, 0.5);
}

.user-role-badge.role-admin {
    background-color: rgba(217, 119, 6, 0.2);
    color: #fde68a;
    border-color: rgba(217, 119, 6, 0.5);
}

.user-role-badge.role-coordinator {
    background-color: rgba(126, 34, 206, 0.2);
    color: #d8b4fe;
    border-color: rgba(126, 34, 206, 0.5);
}

/* --------------------------------------------------------------------------
   4. Layout Container & Page Header
   -------------------------------------------------------------------------- */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 24px 48px 24px;
    width: 100%;
    flex: 1;
}

.page-header,
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title-group h1,
.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--color-navy);
    letter-spacing: -0.01em;
    margin: 0;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Cards & Dossier System
   -------------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 14px 20px;
    background: var(--color-surface-subtle);
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Dossier Header Banner */
.dossier-header {
    background: linear-gradient(135deg, #0b2545 0%, #133a6b 100%);
    color: var(--color-surface);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    border-left: 6px solid var(--color-primary);
}

.dossier-header-identity {
    display: flex;
    align-items: center;
    gap: 20px;
}

.dossier-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}

.dossier-identity-content h1 {
    color: #ffffff;
    font-size: 1.625rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.dossier-tags {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.dossier-identifier-pill {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.8125rem;
}

.dossier-meta {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-top: 8px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* Dossier Grid & Cards */
.dossier-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.dossier-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.dossier-card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--color-border-light);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dossier-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dossier-card-body {
    padding: 20px;
}

.field-pair-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}

.field-pair {
    display: flex;
    flex-direction: column;
}

.field-pair.span-2 {
    grid-column: span 2;
}

.field-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.field-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    word-break: break-word;
}

.field-value.highlight {
    font-weight: 600;
    color: var(--color-navy);
}

.field-value.muted {
    color: var(--color-text-muted);
    font-style: italic;
}

/* --------------------------------------------------------------------------
   6. Transplant Status Badges & Indicators
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
}

/* Primary Clinical Transplant Status Badges */
.badge-pre-transplant {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
}

.badge-on-waitlist {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-border);
}

.badge-assessment {
    background-color: #fef3c7;
    color: #78350f;
    border: 1px solid #fcd34d;
}

.badge-post-transplant {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.badge-suspended {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

.badge-restricted {
    background-color: var(--color-restricted-bg);
    color: var(--color-restricted-text);
    border: 1px solid var(--color-restricted-border);
    font-weight: 800;
}

/* Charity Support Journey Badges */
.badge-journey-waiting {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
}

.badge-journey-transplant {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.badge-journey-donor {
    background-color: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-journey-carer {
    background-color: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
}

.badge-journey-bereaved {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge-journey-chronic {
    background-color: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.badge-peer-mentor {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-weight: 700;
}

/* Generic Fallback Badges */
.badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.badge-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
}

.badge-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

.badge-info {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-border);
}

.badge-secondary {
    background-color: var(--color-surface-subtle);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.25;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled, .btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-primary:focus-visible {
    box-shadow: var(--shadow-focus);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--color-text);
    border-color: var(--color-border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    background-color: var(--color-surface-subtle);
    border-color: #94a3b8;
    color: var(--color-navy);
}

.btn-danger {
    background-color: var(--color-danger);
    color: #ffffff;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background-color: var(--color-danger-dark);
    border-color: var(--color-danger-dark);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8125rem;
    border-radius: var(--radius-xs);
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* --------------------------------------------------------------------------
   8. Form Sectioning & Responsive Grids
   -------------------------------------------------------------------------- */
.form-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-xs);
}

.form-section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-navy);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-border-light);
}

.form-section-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    gap: 18px 20px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 20px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.span-2 {
    grid-column: span 2;
}

.form-group.span-3 {
    grid-column: span 3;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-label .required {
    color: var(--color-danger);
    font-weight: 700;
}

.form-label .helper {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 400;
    margin-left: 6px;
}

.form-control,
.form-select,
textarea.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--color-text);
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--color-surface-subtle);
    cursor: not-allowed;
    color: var(--color-text-muted);
}

/* Form Checkbox & Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.form-check:hover {
    background-color: var(--color-surface-subtle);
    border-color: var(--color-border);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
}

.form-check-desc {
    font-size: 0.775rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   9. Tables, Search Toolbar & Pagination
   -------------------------------------------------------------------------- */
.search-toolbar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.search-toolbar-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-wrap {
    flex: 1;
    min-width: 260px;
    position: relative;
}

.table-container,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.table th,
.data-table th {
    background-color: #f8fafc;
    color: var(--color-navy);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 14px 18px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.table td,
.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
    vertical-align: middle;
}

.table tbody tr,
.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover,
.data-table tbody tr:hover {
    background-color: #f1f5f9;
}

.table tbody tr:last-child td,
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table Inline Action Dropdown Menu */
.table .nav-dropdown {
    position: relative;
    display: inline-block;
}

.table .nav-dropdown-menu,
.table-action-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    min-width: 175px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 4px 0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    text-align: left;
}

.table .nav-dropdown-menu form,
.table-action-dropdown-menu form {
    margin: 0;
}

.table .nav-dropdown-menu .dropdown-action-btn,
.table-action-dropdown-menu .dropdown-action-btn {
    width: 100%;
    padding: 7px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color var(--transition-fast);
}

.table .nav-dropdown-menu .dropdown-action-btn:hover,
.table-action-dropdown-menu .dropdown-action-btn:hover {
    background-color: #f1f5f9;
}

.table .nav-dropdown-menu .dropdown-action-btn.text-danger,
.table-action-dropdown-menu .dropdown-action-btn.text-danger {
    color: #dc2626;
}

.table .nav-dropdown-menu .dropdown-action-btn.text-danger:hover,
.table-action-dropdown-menu .dropdown-action-btn.text-danger:hover {
    background-color: #fef2f2;
}

.table .nav-dropdown-divider,
.table-action-dropdown-menu .dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background-color: #e2e8f0;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    color: #94a3b8;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--color-navy);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 420px;
    margin: 0 auto 16px auto;
}

/* Pagination */
.pagination-container {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--color-border-light);
    background: #ffffff;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.pagination-nav {
    display: flex;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   10. Alerts & Callouts
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.4;
    border: 1px solid transparent;
}

.alert-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.alert-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: var(--color-warning-border);
}

.alert-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-color: var(--color-danger-border);
}

.alert-info {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-color: var(--color-primary-border);
}

/* Restricted Medical Notes Callout */
.callout-restricted {
    background-color: var(--color-restricted-bg);
    border: 1px solid var(--color-restricted-border);
    border-left: 4px solid var(--color-restricted);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.callout-restricted-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-restricted-text);
    margin-bottom: 4px;
}

.callout-restricted-desc {
    font-size: 0.85rem;
    color: #6b21a8;
    line-height: 1.45;
}

/* Clinical Notes Box */
.clinical-notes-box {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    white-space: pre-wrap;
    font-family: inherit;
}

/* --------------------------------------------------------------------------
   11. Metrics Grid (Dashboard, Grants, Bursaries, Outreach, Reports & Import)
   -------------------------------------------------------------------------- */
.metric-grid,
.stats-grid,
.metric-card-grid,
.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card,
.stat-card,
.report-kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card:hover,
.stat-card:hover,
.report-kpi-card:hover {
    box-shadow: var(--shadow-md);
}

.metric-label,
.stat-label,
.report-kpi-lbl {
    display: block;
    font-size: 0.775rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.metric-value,
.stat-value,
.report-kpi-val {
    display: block;
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--color-navy);
    line-height: 1.1;
    margin-bottom: 6px;
}

.metric-value.primary, .stat-value.primary { color: var(--color-primary); }
.metric-value.success, .stat-value.success { color: var(--color-success); }
.metric-value.warning, .stat-value.warning { color: var(--color-warning); }
.metric-value.danger, .stat-value.danger { color: var(--color-danger); }

.metric-caption,
.stat-desc {
    display: flex;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    align-items: center;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   12. Two-Phase CSV Import Drag-Drop & Staging Diff
   -------------------------------------------------------------------------- */
.dropzone {
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    background-color: #f0f9ff;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropzone:hover, .dropzone:focus-within {
    background-color: #e0f2fe;
    border-color: var(--color-primary-hover);
}

.dropzone-icon {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.dropzone-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-navy);
    margin-bottom: 4px;
}

.dropzone-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.diff-tag-change {
    background-color: #fef3c7;
    color: #78350f;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    font-weight: 600;
}

.diff-tag-conflict {
    background-color: #fef2f2;
    color: #991b1b;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid #fecaca;
}

.diff-existing {
    text-decoration: line-through;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}

.diff-incoming {
    font-weight: 600;
    color: var(--color-navy);
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   12b. Target Deep-Link Pulse Animations (BUG-006)
   -------------------------------------------------------------------------- */
:target {
    animation: target-pulse 2.5s ease-out;
}

tr:target td,
tr:target th {
    background-color: #e0f2fe !important;
    animation: target-pulse-row 2.5s ease-out forwards;
}

@keyframes target-pulse {
    0% {
        background-color: #bae6fd;
    }
    40% {
        background-color: #e0f2fe;
    }
    100% {
        background-color: transparent;
    }
}

@keyframes target-pulse-row {
    0% {
        background-color: #bae6fd;
    }
    40% {
        background-color: #e0f2fe;
    }
    100% {
        background-color: inherit;
    }
}

/* --------------------------------------------------------------------------
   13. Footer & Clinical Guidance
   -------------------------------------------------------------------------- */
.footer {
    background-color: #ffffff;
    border-top: 1px solid var(--color-border);
    padding: 24px 24px;
    margin-top: auto;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-emergency-note {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: #78350f;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.footer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--color-border-light);
    padding-top: 12px;
}

.footer-meta span {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   14. Responsive Breakpoints & Mobile Bottom Navigation (Thumb Zone)
   -------------------------------------------------------------------------- */
.navbar-bottom-mobile {
    display: none;
}

@media (max-width: 1023px) {
    .navbar {
        padding: 0 16px;
    }

    .navbar-inner {
        height: 56px;
        gap: 12px;
    }

    .navbar-brand {
        flex-shrink: 1;
        min-width: 0;
        gap: 8px;
    }

    .navbar-brand-subtitle {
        display: none !important;
    }

    .navbar-brand-title {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .navbar-desktop {
        display: none !important;
    }

    .user-profile-btn {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: none !important;
    }

    .dossier-grid {
        grid-template-columns: 1fr;
    }

    /* Fixed Bottom Navigation Bar */
    .navbar-bottom-mobile {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        min-height: 64px;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        background: #0b2545;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.4);
        z-index: 9999;
        align-items: stretch;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }

    /* Provide space at bottom of document so content is never obscured */
    body {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    .nav-bottom-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #94a3b8;
        text-decoration: none;
        background: transparent;
        border: none;
        border-top: 3px solid transparent;
        padding: 6px 2px 4px 2px;
        cursor: pointer;
        font-family: inherit;
        font-size: 0.72rem;
        font-weight: 600;
        transition: all var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
        min-width: 0;
    }

    .nav-bottom-item:hover,
    .nav-bottom-item:focus-visible {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.05);
    }

    .nav-bottom-item.active {
        color: #38bdf8;
        border-top-color: #38bdf8;
        background: rgba(2, 132, 199, 0.14);
    }

    .nav-bottom-item svg {
        flex-shrink: 0;
    }

    .nav-bottom-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        line-height: 1;
        letter-spacing: 0.01em;
    }
}

@media (min-width: 1024px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .navbar-bottom-mobile {
        display: none !important;
    }

    .mobile-drawer,
    .drawer-backdrop {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .footer {
        padding: 20px 16px;
    }

    .footer-meta {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 8px;
    }

    .footer-emergency-note,
    .footer-meta span {
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }

    .form-grid-2,
    .form-grid-3,
    .field-pair-grid {
        grid-template-columns: 1fr;
    }

    .field-pair.span-2,
    .form-group.span-2,
    .form-group.span-3 {
        grid-column: span 1;
    }

    .dossier-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-toolbar-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-wrap {
        width: 100%;
    }
}

/* ==========================================================================
   14. Modern Centered Authentication Experience
   ========================================================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 25%, rgba(2, 132, 199, 0.18) 0%, transparent 55%),
                radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
                linear-gradient(135deg, #07192f 0%, #0b2545 50%, #0d1f38 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

.auth-page::before {
    content: "";
    position: absolute;
    width: 650px;
    height: 650px;
    top: -180px;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(56, 189, 248, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: authFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(7, 25, 47, 0.45),
                0 0 0 1px rgba(255, 255, 255, 0.1),
                0 10px 15px -3px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.85);
    overflow: hidden;
    position: relative;
}

.auth-card-accent {
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, #0284c7 0%, #10b981 50%, #0284c7 100%);
    background-size: 200% 100%;
    animation: authShimmer 6s linear infinite;
}

@keyframes authShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.auth-header {
    text-align: center;
    padding: 32px 28px 16px 28px;
}

.auth-logo-badge {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px auto;
    border-radius: 16px;
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    border: 1px solid #bae6fd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0284c7;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.15);
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}

.auth-subtitle {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0 0 10px 0;
    font-weight: 500;
}

.auth-security-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 9999px;
    padding: 3px 10px;
    font-size: 0.725rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Interactive Segmented Switcher */
.auth-segmented-nav {
    display: flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    margin: 8px 24px 20px 24px;
    gap: 4px;
    border: 1px solid #e2e8f0;
}

.auth-segmented-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    white-space: nowrap;
}

.auth-segmented-btn:hover {
    color: #0f172a;
}

.auth-segmented-btn.active {
    background: #ffffff;
    color: #0284c7;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.auth-body {
    padding: 0 28px 24px 28px;
}

/* Passkey Hero View */
.passkey-hero-box {
    text-align: center;
    padding: 10px 0 12px 0;
}

.passkey-illustration {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px auto;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 8px rgba(224, 242, 254, 0.4);
}

.passkey-hero-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.passkey-hero-desc {
    font-size: 0.825rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}

.btn-passkey-hero {
    width: 100%;
    padding: 13px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    transition: all 0.2s ease;
}

.btn-passkey-hero:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.45);
    transform: translateY(-1px);
}

.btn-passkey-hero:active {
    transform: translateY(0);
}

.btn-passkey-hero:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* TOTP Form Inputs */
.auth-input-group {
    position: relative;
    margin-bottom: 16px;
}

.auth-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    font-size: 0.9375rem;
    border-radius: 9px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    transition: all 0.15s ease;
}

.auth-input:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.btn-auth-submit {
    width: 100%;
    padding: 12px 18px;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 9px;
    background: #0b2545;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.btn-auth-submit:hover {
    background: #133a6b;
    box-shadow: 0 4px 12px rgba(11, 37, 69, 0.25);
    transform: translateY(-1px);
}

/* Demo Role Switcher */
.auth-demo-section {
    margin-top: 22px;
    padding: 14px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.auth-demo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.auth-demo-badge {
    font-size: 0.675rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #0369a1;
    background: #e0f2fe;
    padding: 2px 7px;
    border-radius: 4px;
}

.auth-demo-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.auth-demo-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.auth-demo-btn:hover {
    border-color: #0284c7;
    background: #f0f9ff;
    transform: translateY(-1px);
}

.auth-demo-btn-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 4px;
}

.auth-demo-btn-desc {
    font-size: 0.675rem;
    color: #64748b;
    margin-top: 2px;
}

.auth-footer {
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    padding: 14px 20px;
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ==========================================================================
   Forensic Audit Trail & Inspector Styles
   ========================================================================== */

.audit-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.audit-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.audit-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.audit-kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.audit-kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.audit-kpi-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 700;
}

.audit-kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.audit-kpi-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* Audit Category Tabs */
.audit-category-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.audit-tab-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.audit-tab-link:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.audit-tab-link.active {
    color: #0284c7;
    background: #e0f2fe;
}

/* Slide-out Drawer & Overlay */
.audit-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 9998;
    transition: opacity 0.2s ease;
}

.audit-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 540px;
    max-width: 100vw;
    background: #ffffff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: drawerSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.audit-drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: #f8fafc;
}

.audit-drawer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.drawer-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
}

.drawer-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    margin: 0 0 10px 0;
}

.drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.drawer-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    margin-bottom: 2px;
}

.drawer-value {
    font-size: 0.875rem;
    color: #0f172a;
}

.drawer-code-small {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.725rem;
    color: #334155;
    background: #ffffff;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    word-break: break-all;
}

/* Diff Table */
.diff-table {
    margin: 0;
    font-size: 0.8125rem;
}

.diff-table th {
    background: #e2e8f0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px 10px;
}

.diff-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.diff-from del {
    background: #fee2e2;
    color: #991b1b;
    padding: 2px 6px;
    border-radius: 4px;
    text-decoration: line-through;
}

.diff-to ins {
    background: #dcfce7;
    color: #166534;
    padding: 2px 6px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}

/* JSON Code Block */
.json-code-block {
    background: #0f172a;
    color: #38bdf8;
    padding: 12px 14px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.45;
    max-height: 280px;
    overflow: auto;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Modal Dialogs (CSP-Compliant & Accessible Scroll Locked)
   -------------------------------------------------------------------------- */
html.modal-open,
body.modal-open {
    overflow: hidden !important;
}

.grant-modal-backdrop,
.modal-backdrop,
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.grant-modal-content,
.modal-content,
.modal-container {
    background: var(--color-surface, #ffffff);
    color: var(--color-text, #1e293b);
    max-width: 520px;
    width: 100%;
    margin: auto;
    padding: 24px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-border, #e2e8f0);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    position: relative;
    box-sizing: border-box;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.grant-detail-modal {
    max-width: 640px !important;
}

@media (max-width: 640px) {
    .grant-modal-backdrop,
    .modal-backdrop,
    .modal-overlay {
        padding: 12px 8px;
    }

    .grant-modal-content,
    .modal-content,
    .modal-container {
        padding: 18px 16px;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: var(--radius-sm, 6px);
    }
}

/* --------------------------------------------------------------------------
   Charity Reporting & Governance Hub (IMPROVE-011)
   -------------------------------------------------------------------------- */
.report-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    background: rgba(2, 132, 199, 0.08);
    border: 1px solid rgba(2, 132, 199, 0.25);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.report-audit-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.report-tab-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.report-tab-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.report-tab-item:hover {
    color: var(--color-primary);
    background: rgba(2, 132, 199, 0.08);
    text-decoration: none;
}

.report-tab-item.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

.report-filter-card {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.report-filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.report-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.report-filter-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.report-filter-field .form-control {
    height: 38px;
    font-size: 0.8125rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.report-filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-filter-actions .btn {
    height: 38px;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
}

.report-table-fixed {
    table-layout: fixed;
    width: 100%;
}

.report-cell-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-cell-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.35;
}

.report-num-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.report-progress-bar {
    width: 70px;
    height: 7px;
    background: var(--color-border-light);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
}

.report-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.report-progress-fill-primary {
    background: var(--color-primary);
}

.report-progress-fill-sky {
    background: #0284c7;
}

.report-progress-fill-emerald {
    background: #10b981;
}

.report-progress-fill-violet {
    background: #8b5cf6;
}

.report-statutory-card {
    margin-bottom: 24px;
    padding: 18px 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* --------------------------------------------------------------------------
   Unified Utility, Badge, Button & Responsive Grid Classes
   -------------------------------------------------------------------------- */
.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
    background: var(--color-surface-subtle);
    color: var(--color-text);
    text-decoration: none;
}

.badge-primary {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-border);
}

.badge-secondary {
    background-color: var(--color-surface-subtle);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.badge-light {
    background-color: var(--color-surface-subtle);
    color: var(--color-text);
    border: 1px solid var(--color-border-light);
}

.text-slate-800 {
    color: var(--color-navy) !important;
}

.text-slate-700 {
    color: var(--color-text) !important;
}

.form-control-sm,
.form-select-sm {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.row > [class*="col-"] {
    min-width: 0;
}

.grid-2col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-3col {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.grid-2fr-1fr {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.grid-1fr-2fr {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

.broadcast-layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 991.98px) {
    .broadcast-layout-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .form-grid,
    .grid-2col,
    .grid-3col,
    .grid-2fr-1fr,
    .grid-1fr-2fr {
        grid-template-columns: 1fr !important;
    }

    .table-container .report-table-fixed {
        min-width: 640px;
    }

    .btn-sm,
    .btn-xs,
    .table-action-btn {
        min-height: 36px;
    }
}

/* ==========================================================================
   WCAG 2.2 AA & NHS Digital Dark Theme & Contrast Calibration (IMPROVE-032)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #0b1120;
        --color-surface: #1e293b;
        --color-surface-subtle: #0f172a;
        --color-surface-hover: #334155;
        --color-text: #f8fafc;
        --color-text-muted: #cbd5e1;
        --color-text-light: #94a3b8;
        --color-border: #334155;
        --color-border-light: #1e293b;
        --color-navy: #f1f5f9;
        --color-navy-dark: #ffffff;
        --color-navy-light: #e2e8f0;
        --bs-body-bg: #0b1120;
        --bs-body-color: #f8fafc;
        --primary: var(--color-primary);
        --text-muted: var(--color-text-muted);
        --success: var(--color-success);
        --color-text-emphasis: #f8fafc;
        --color-bg-secondary: #0f172a;
    }

    :root:not([data-theme="light"]) body {
        background-color: var(--color-bg);
        color: var(--color-text);
    }

    :root:not([data-theme="light"]) .card,
    :root:not([data-theme="light"]) .report-statutory-card,
    :root:not([data-theme="light"]) .modal-content,
    :root:not([data-theme="light"]) .modal-container,
    :root:not([data-theme="light"]) .grant-modal-content,
    :root:not([data-theme="light"]) .nav-dropdown-menu {
        background-color: var(--color-surface);
        border-color: var(--color-border);
        color: var(--color-text);
    }

    :root:not([data-theme="light"]) .table,
    :root:not([data-theme="light"]) table {
        color: var(--color-text);
        border-color: var(--color-border);
    }

    :root:not([data-theme="light"]) th {
        background-color: #0f172a;
        color: #f1f5f9;
        border-bottom-color: var(--color-border);
    }

    :root:not([data-theme="light"]) td {
        border-color: var(--color-border);
    }

    :root:not([data-theme="light"]) tr:hover td {
        background-color: #334155;
    }

    :root:not([data-theme="light"]) input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
    :root:not([data-theme="light"]) select,
    :root:not([data-theme="light"]) textarea {
        background-color: #0f172a;
        border-color: #475569;
        color: #f8fafc;
    }

    :root:not([data-theme="light"]) input::placeholder,
    :root:not([data-theme="light"]) textarea::placeholder {
        color: #94a3b8;
    }

    :root:not([data-theme="light"]) .badge-restricted {
        background-color: #3b0764;
        color: #f3e8ff;
        border: 1px solid #9333ea;
    }

    :root:not([data-theme="light"]) .badge-success {
        background-color: #052e16;
        color: #86efac;
        border: 1px solid #16a34a;
    }

    :root:not([data-theme="light"]) .badge-warning {
        background-color: #451a03;
        color: #fde047;
        border: 1px solid #d97706;
    }

    :root:not([data-theme="light"]) .badge-danger {
        background-color: #450a0a;
        color: #fca5a5;
        border: 1px solid #dc2626;
    }

    :root:not([data-theme="light"]) .badge-primary {
        background-color: #082f49;
        color: #7dd3fc;
        border: 1px solid #0284c7;
    }
}

[data-theme="dark"] {
    --color-bg: #0b1120;
    --color-surface: #1e293b;
    --color-surface-subtle: #0f172a;
    --color-surface-hover: #334155;
    --color-text: #f8fafc;
    --color-text-muted: #cbd5e1;
    --color-text-light: #94a3b8;
    --color-border: #334155;
    --color-border-light: #1e293b;
    --color-navy: #f1f5f9;
    --color-navy-dark: #ffffff;
    --color-navy-light: #e2e8f0;
    --bs-body-bg: #0b1120;
    --bs-body-color: #f8fafc;
    --primary: var(--color-primary);
    --text-muted: var(--color-text-muted);
    --success: var(--color-success);
    --color-text-emphasis: #f8fafc;
    --color-bg-secondary: #0f172a;
}

[data-theme="dark"] body {
    background-color: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .card,
[data-theme="dark"] .report-statutory-card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-container,
[data-theme="dark"] .grant-modal-content,
[data-theme="dark"] .nav-dropdown-menu {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

[data-theme="dark"] .table,
[data-theme="dark"] table {
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] th {
    background-color: #0f172a;
    color: #f1f5f9;
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] td {
    border-color: var(--color-border);
}

[data-theme="dark"] tr:hover td {
    background-color: #334155;
}

[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: #0f172a;
    border-color: #475569;
    color: #f8fafc;
}

[data-theme="dark"] .badge-restricted {
    background-color: #3b0764;
    color: #f3e8ff;
    border: 1px solid #9333ea;
}

[data-theme="dark"] .badge-success {
    background-color: #052e16;
    color: #86efac;
    border: 1px solid #16a34a;
}

[data-theme="dark"] .badge-warning {
    background-color: #451a03;
    color: #fde047;
    border: 1px solid #d97706;
}

[data-theme="dark"] .badge-danger {
    background-color: #450a0a;
    color: #fca5a5;
    border: 1px solid #dc2626;
}

[data-theme="dark"] .badge-primary {
    background-color: #082f49;
    color: #7dd3fc;
    border: 1px solid #0284c7;
}

/* ==========================================================================
   19. Data Display & Navigation Architecture Ergonomics
   ========================================================================== */
.nav-dropdown-header {
    padding: 8px 16px 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

[data-theme="dark"] .nav-dropdown-header {
    color: #94a3b8;
}

.table-num, th.table-num, td.table-num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.table-date, td.table-date {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.table-actions, th.table-actions, td.table-actions {
    text-align: right !important;
    white-space: nowrap;
}

.table-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}




/* ==========================================================================
   20. Modern Ultra-Clean SaaS UI Component System & Micro-Animations
   Strictly Zero-CDN • Accessible WCAG 2.1 AA/AAA • Tactile Interactions
   ========================================================================== */

/* --------------------------------------------------------------------------
   A. Keyframe Animations & Reduced-Motion Ergonomics
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulseDot {
    0% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.delay-1 { animation-delay: 40ms; }
.delay-2 { animation-delay: 80ms; }
.delay-3 { animation-delay: 120ms; }
.delay-4 { animation-delay: 160ms; }

.icon-spin {
    animation: spin 0.8s linear infinite;
}

/* --------------------------------------------------------------------------
   B. Button Micro-Interactions & State Refinements
   -------------------------------------------------------------------------- */
.btn {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:active {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-surface, #ffffff), 0 0 0 4px var(--color-primary, #0284c7) !important;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
    border-color: #94a3b8;
}

.btn-danger-subtle {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    box-shadow: var(--shadow-xs);
}

.btn-danger-subtle:hover {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
    transform: translateY(-1px);
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-text-muted);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background-color: var(--color-surface-subtle);
    color: var(--color-navy);
}

/* --------------------------------------------------------------------------
   C. SVG Icons Standard Sizing
   -------------------------------------------------------------------------- */
.svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   D. Modern Live System Status / Privacy Trust Bar
   -------------------------------------------------------------------------- */
.saas-trust-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 24px;
}

.saas-trust-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
}

.live-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #16a34a;
    display: inline-block;
    animation: pulseDot 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.saas-trust-banner-title {
    color: var(--color-navy);
    font-weight: 600;
}

.saas-trust-banner-meta {
    color: #64748b;
}

/* --------------------------------------------------------------------------
   E. KPI Stat Cards & Metric System
   -------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -4px rgba(15, 23, 42, 0.08);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.stat-card-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon-wrap.tone-primary {
    background-color: #e0f2fe;
    color: #0284c7;
}

.stat-card-icon-wrap.tone-success {
    background-color: #f0fdf4;
    color: #16a34a;
}

.stat-card-icon-wrap.tone-neutral {
    background-color: #f1f5f9;
    color: #475569;
}

.stat-card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin: 12px 0 8px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-card-value.stat-value-primary {
    color: var(--color-primary);
}

.stat-card-value.stat-value-success {
    color: var(--color-success);
}

.stat-card-value.stat-value-warning {
    color: var(--color-warning);
}

.stat-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.stat-card-caption-icon {
    display: inline-flex;
    align-items: center;
}

.stat-card-caption-icon.text-success {
    color: var(--color-success);
}

.stat-card-caption-icon.text-primary {
    color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   F. SaaS Action Tiles (Quick Actions Grid)
   -------------------------------------------------------------------------- */
.action-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.action-tile {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-tile:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(15, 23, 42, 0.08);
}

.action-tile-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-tile:hover .action-tile-icon-box {
    transform: scale(1.06);
}

.tile-tone-primary .action-tile-icon-box {
    background-color: #e0f2fe;
    color: #0284c7;
}

.tile-tone-success .action-tile-icon-box {
    background-color: #f0fdf4;
    color: #16a34a;
}

.tile-tone-purple .action-tile-icon-box {
    background-color: #faf5ff;
    color: #9333ea;
}

.tile-tone-warning .action-tile-icon-box {
    background-color: #fffbeb;
    color: #d97706;
}

.tile-tone-neutral .action-tile-icon-box {
    background-color: #f1f5f9;
    color: #475569;
}

.action-tile-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.action-tile-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-navy);
    line-height: 1.3;
}

.action-tile-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    line-height: 1.3;
}

.action-tile-arrow {
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, color 0.18s ease;
}

.action-tile:hover .action-tile-arrow {
    transform: translateX(3px);
    color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   G. Modern Status Badges & Dots
   -------------------------------------------------------------------------- */
.saas-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    line-height: 1.25;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    background-color: currentColor;
}

/* --------------------------------------------------------------------------
   H. Table Row Interactions & Polish
   -------------------------------------------------------------------------- */
.table tbody tr {
    transition: background-color 0.12s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* --------------------------------------------------------------------------
   I. Reduced-Motion Media Query (WCAG 2.1 AAA Compliance)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .live-pulse-dot {
        animation: none !important;
    }
}