/**
 * NG-CDF Integrated Digital Platform — Core Design System
 * Compliant with docs/design-guide.md master specifications.
 * Provides unified design tokens, typography, component library,
 * data tables, status badges, and system states across all 290 portals.
 */

/* ==========================================================================
   1. GLOBAL DESIGN TOKENS & VARIABLES (:root)
   ========================================================================== */
:root {
    /* Primary Institutional Kenya Palette */
    --primary: #007a53;
    --primary-dark: #005a3c;
    --primary-light: #e6f5ef;
    --primary-hover: #006847;
    
    /* Secondary & Dark Surfaces */
    --secondary: #070d1e;
    --secondary-light: #152342;
    --dark: #0f172a;
    --dark-surface: #1e293b;
    --dark-card: #131d36;

    /* Accents & National Colors */
    --accent: #eab308;
    --accent-hover: #ca8a04;
    --accent-light: #fefce8;
    --kenya-red: #bb0000;
    --kenya-black: #000000;
    --kenya-green: #007a53;

    /* Functional Semantics */
    --success: #16a34a;
    --success-light: #dcfce7;
    --success-dark: #14532d;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --warning-dark: #78350f;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --danger-dark: #7f1d1d;
    --info: #0284c7;
    --info-light: #e0f2fe;
    --info-dark: #0c4a6e;

    /* Neutrals & Surfaces */
    --text-main: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --border: #e2e8f0;
    --border-dark: #334155;
    --bg-page: #f8fafc;
    --surface: #ffffff;

    /* Typography Families */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Radius Tokens */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Elevation & Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 35px -5px rgba(0, 0, 0, 0.15);

    /* Animation Timing */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout Tokens & Breakpoint Constraints */
    --max-content-width: 1600px;
    --page-padding-desktop: 2rem;
    --page-padding-tablet: 1.5rem;
    --page-padding-mobile: 1rem;
    --page-padding-compact: 0.75rem;
    --page-padding: clamp(0.75rem, 2.5vw, 2rem);

    /* Mobile App-Like Tokens & Touch Constraints */
    --touch-target-min: 44px;
    --touch-target-compact: 38px;
    --radius-mobile: 12px;
    --shadow-mobile-card: 0 2px 10px rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   2. GLOBAL TYPOGRAPHY SCALE, RESET & ZERO-OVERFLOW SAFEGUARDS
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    overflow-x: clip;
    max-width: 100%;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
    max-width: 100%;
    position: relative;
    margin: 0;
    padding: 0;
}

/* Standardized 1600px Global Content Containers */
.container,
.page-container,
.content-container,
.hero-container,
.section-container,
.portal-container,
.nav-container,
.footer-container,
.portal-subpage-nav-container,
.wrapper {
    max-width: var(--max-content-width);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Fluid Media Resets */
img, svg, video, canvas, iframe {
    max-width: 100%;
    height: auto;
}

/* Fluid Typography Scale */
h1, h2, h3, h4, h5, h6,
.text-display, .text-h1, .text-h2, .text-h3, .text-h4 {
    font-family: var(--font-heading);
    color: var(--dark);
    font-weight: 700;
    line-height: 1.25;
}

/* Universal Safeguard: Ensure headings on dark/gradient hero backgrounds stay crisp white */
.hero h1, .hero h2, .hero h3, .hero h4,
.alloc-hero h1, .alloc-hero h2, .alloc-hero h3, .alloc-hero h4,
.disb-hero h1, .disb-hero h2, .disb-hero h3, .disb-hero h4,
.members-hero h1, .members-hero h2, .members-hero h3, .members-hero h4,
.page-header h1, .page-header h2, .page-header h3, .page-header h4,
.c-grievance-banner h1, .c-grievance-banner h2, .c-grievance-banner h3, .c-grievance-banner h4,
.bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark h4,
.contact-strip h1, .contact-strip h2, .contact-strip h3, .contact-strip h4,
.dark-hero h1, .dark-hero h2, .dark-hero h3, .dark-hero h4,
[class*="-hero"] h1, [class*="-hero"] h2, [class*="-hero"] h3,
.c-hero h1, .c-hero h2, .c-hero h3 {
    color: #ffffff !important;
}

.text-display {
    font-size: clamp(1.75rem, 3.8vw, 2.45rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.text-h1, h1 {
    font-size: clamp(1.35rem, 2.5vw + 0.15rem, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.text-h2, h2 {
    font-size: clamp(1.15rem, 1.8vw + 0.12rem, 1.45rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.text-h3, h3 {
    font-size: clamp(1.1rem, 1.8vw + 0.2rem, 1.35rem);
    font-weight: 700;
    line-height: 1.3;
}

.text-h4, h4 {
    font-size: clamp(0.95rem, 1.2vw + 0.2rem, 1.15rem);
    font-weight: 700;
}

.text-lead {
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.125rem);
    line-height: 1.65;
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.text-meta {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-muted);
}

/* ==========================================================================
   3. BUTTON & ACTION SUITE (.btn)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 0.55rem 1.15rem;
    min-height: 40px;
    transition: all var(--transition-fast);
    line-height: 1.2;
    white-space: nowrap;
}

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

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 122, 83, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--text-inverse);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 83, 0.35);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--text-inverse);
    border-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: var(--secondary-light);
    color: var(--text-inverse);
}

.btn-accent {
    background-color: var(--accent);
    color: var(--dark);
    border-color: var(--accent-hover);
    font-weight: 700;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
    color: var(--dark);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-outline:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--dark);
}

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

.btn-outline-primary:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-inverse);
    border-color: var(--danger);
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    min-height: 32px;
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
    min-height: 48px;
}

/* ==========================================================================
   4. STATUS BADGES & PILLS (.badge)
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

/* Project Lifecycle States */
.badge-COMPLETED, .badge-COMMISSIONED, .badge-completed,
.status-COMPLETED, .status-COMMISSIONED {
    background-color: var(--success-light);
    color: var(--success-dark);
    border: 1px solid rgba(22, 163, 74, 0.25);
}

.badge-ONGOING, .badge-ongoing,
.status-ONGOING {
    background-color: var(--info-light);
    color: var(--info-dark);
    border: 1px solid rgba(2, 132, 199, 0.25);
}

.badge-PROCUREMENT, .badge-APPROVED, .badge-procurement,
.status-PROCUREMENT, .status-APPROVED {
    background-color: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid rgba(217, 119, 6, 0.25);
}

.badge-STALLED, .badge-stalled,
.status-STALLED {
    background-color: var(--danger-light);
    color: var(--danger-dark);
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.badge-PROPOSED, .badge-SUBMITTED, .badge-proposed,
.status-PROPOSED, .status-SUBMITTED {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid #cbd5e1;
}

/* Severity Indicators */
.badge-critical {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.badge-high {
    background-color: #ffedd5;
    color: #9a3412;
    border: 1px solid #f97316;
}

.badge-medium {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.badge-low {
    background-color: #e0f2fe;
    color: #075985;
    border: 1px solid #38bdf8;
}

/* Priority Indicators */
.badge-urgent {
    background-color: #fee2e2;
    color: #991b1b;
    animation: pulseGlow 2s infinite;
}

/* ==========================================================================
   5. CARDS & CONTAINERS (.card, .stat-card, .content-card)
   ========================================================================== */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-modern {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.card-modern:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 77, 52, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 122, 83, 0.35);
}

.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-lg);
}

.content-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.75rem;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* KPI Statistics Cards */
.stat-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-green {
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-icon-blue {
    background-color: var(--info-light);
    color: var(--info);
}

.stat-icon-gold {
    background-color: var(--accent-light);
    color: var(--accent-hover);
}

.stat-icon-red {
    background-color: var(--danger-light);
    color: var(--danger);
}

.stat-meta {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    font-family: var(--font-heading);
    line-height: 1.1;
}

/* ==========================================================================
   6. DATA TABLES & FILTER BARS (.data-table)
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

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

.data-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 0.85rem 1.25rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    vertical-align: middle;
}

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

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

.filter-bar {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Accessible Form Controls (Section 88 & Touch Area >= 44px) */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1rem;
}

.form-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-control, .form-input, .form-select {
    width: 100%;
    min-height: 44px;
    padding: 0.6rem 1rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    -webkit-appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 10px;
    padding-right: 2.25rem;
}

.form-control:focus, .form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 83, 0.18);
}

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

/* ==========================================================================
   7. SKELETON LOADERS & SYSTEM STATES
   ========================================================================== */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    width: 60%;
}

.skeleton-img {
    height: 200px;
    width: 100%;
    border-radius: var(--radius-md);
}

.skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-pill {
    height: 26px;
    width: 80px;
    border-radius: 9999px;
}

.skeleton-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-table-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

/* Skip to Content Accessible Link (WCAG 2.1 AA) */
.skip-to-content {
    position: absolute;
    top: -9999px;
    left: 20px;
    z-index: 100000;
    background: var(--primary);
    color: #ffffff !important;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    transition: top 0.15s ease-in-out;
}

.skip-to-content:focus {
    top: 20px;
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    margin: 1.5rem 0;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.empty-state-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
}

/* ==========================================================================
   8. TOAST NOTIFICATION CONTAINER
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 420px;
    width: 100%;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    background: #0f172a;
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideUp 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

/* ==========================================================================
   9. ACCESSIBILITY & MICRO-INTERACTIONS
   ========================================================================== */
:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

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

@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;
    }
}

/* High Contrast Mode */
body.high-contrast {
    --text-main: #000000 !important;
    --text-muted: #111827 !important;
    --border: #000000 !important;
    --bg-page: #ffffff !important;
    --surface: #ffffff !important;
    filter: contrast(1.15);
}

/* Standardized Sticky Navigation Bar */
.navbar {
    width: 100%;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.navbar.navbar-scrolled {
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.12);
    border-bottom-color: rgba(203, 213, 225, 0.8);
}

/* Responsive Navigation Bar */
@media (max-width: 1200px) {
    .navbar .nav-links {
        display: none !important;
    }
    .mobile-nav-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

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

/* ========================================================================
   10. PLATFORM-WIDE RESPONSIVE SURFACE
   Keeps public portal pages fluid even where individual templates use
   compact inline grid declarations for their desktop presentation.
   ======================================================================== */
@media (max-width: 1024px) {
    body:not(:has(.console-app-container)) .section-container,
    body:not(:has(.console-app-container)) .page-header-container,
    body:not(:has(.console-app-container)) .portal-subpage-nav-container,
    body:not(:has(.console-app-container)) .c-breadcrumb-container {
        padding-left: var(--page-padding-tablet);
        padding-right: var(--page-padding-tablet);
    }

    body:not(:has(.console-app-container)) .hero-container,
    body:not(:has(.console-app-container)) .c-hero-content,
    body:not(:has(.console-app-container)) .page-header-content {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body:not(:has(.console-app-container)) .footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2rem;
    }

    body:not(:has(.console-app-container)) [style*="grid-template-columns"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    body:not(:has(.console-app-container)) .card,
    body:not(:has(.console-app-container)) .card-modern,
    body:not(:has(.console-app-container)) .content-card {
        min-width: 0;
    }
}

@media (max-width: 680px) {
    body:not(:has(.console-app-container)) .section-container,
    body:not(:has(.console-app-container)) .page-header-container,
    body:not(:has(.console-app-container)) .portal-subpage-nav-container,
    body:not(:has(.console-app-container)) .c-breadcrumb-container {
        padding-left: var(--page-padding-mobile);
        padding-right: var(--page-padding-mobile);
    }

    body:not(:has(.console-app-container)) .footer-grid,
    body:not(:has(.console-app-container)) [style*="grid-template-columns"],
    body:not(:has(.console-app-container)) .form-row,
    body:not(:has(.console-app-container)) .form-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body:not(:has(.console-app-container)) .content-card {
        padding: 1rem;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }

    body:not(:has(.console-app-container)) .filter-bar,
    body:not(:has(.console-app-container)) .form-actions,
    body:not(:has(.console-app-container)) .c-hero-actions {
        align-items: stretch;
        flex-direction: column;
    }

    body:not(:has(.console-app-container)) .filter-bar > *,
    body:not(:has(.console-app-container)) .form-actions > *,
    body:not(:has(.console-app-container)) .c-hero-actions > * {
        width: 100%;
        max-width: none;
    }

    body:not(:has(.console-app-container)) .btn,
    body:not(:has(.console-app-container)) button,
    body:not(:has(.console-app-container)) input,
    body:not(:has(.console-app-container)) select,
    body:not(:has(.console-app-container)) textarea {
        min-height: 44px;
    }

    body:not(:has(.console-app-container)) .data-table,
    body:not(:has(.console-app-container)) table {
        font-size: 0.8rem;
    }

    body:not(:has(.console-app-container)) .data-table th,
    body:not(:has(.console-app-container)) .data-table td {
        padding: 0.7rem 0.8rem;
    }

    body:not(:has(.console-app-container)) .table-responsive {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }

    body:not(:has(.console-app-container)) .empty-state {
        padding: 2.5rem 1rem;
    }

    body:not(:has(.console-app-container)) footer {
        margin-top: 2.5rem;
        padding: 2.5rem var(--page-padding-mobile) 1.5rem;
    }
}

/* ==========================================================================
   11. ENHANCED MULTI-LEVEL GOVERNMENT NAVIGATION MENU
   ========================================================================== */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 3px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.nav-item {
    position: relative;
    flex-shrink: 0;
}

.nav-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    font-size: 0.81rem;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
    border: none;
}

.nav-link-btn i {
    margin-right: 0 !important;
    font-size: 0.78rem !important;
}

.nav-link-btn:hover,
.nav-item:hover > .nav-link-btn,
.nav-item:focus-within > .nav-link-btn {
    color: var(--primary);
    background-color: var(--primary-light);
}

.nav-link-btn.active {
    color: var(--primary);
    font-weight: 700;
}

.nav-link-btn .chevron-icon {
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
    opacity: 0.7;
}

.nav-item:hover > .nav-link-btn .chevron-icon,
.nav-item:focus-within > .nav-link-btn .chevron-icon,
.nav-item.is-open > .nav-link-btn .chevron-icon {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown Menu Container */
.nav-dropdown {
    position: absolute;
    top: 100%;
    margin-top: 4px;
    left: 0;
    min-width: 270px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1100;
    pointer-events: none;
}

/* Invisible bridge preventing hover-loss between button and dropdown menu */
.nav-dropdown::before {
    content: "";
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    height: 14px;
    background: transparent;
    display: block;
    pointer-events: auto;
}

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

.nav-item:hover > .nav-dropdown,
.nav-item:focus-within > .nav-dropdown,
.nav-item.is-open > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-dropdown-header {
    padding: 6px 12px 4px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 6px 0;
}

.nav-dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-main);
    transition: background-color var(--transition-fast);
}

.nav-dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.nav-dropdown-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: 1px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Multi-Color Domain Color Classes for Dropdown Icons & Badges */
.nav-dropdown-icon.c-azure, .icon-badge.c-azure { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.nav-dropdown-icon.c-emerald, .icon-badge.c-emerald { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.nav-dropdown-icon.c-violet, .icon-badge.c-violet { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }
.nav-dropdown-icon.c-amber, .icon-badge.c-amber { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.nav-dropdown-icon.c-coral, .icon-badge.c-coral { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.nav-dropdown-icon.c-rose, .icon-badge.c-rose { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }
.nav-dropdown-icon.c-cyan, .icon-badge.c-cyan { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }
.nav-dropdown-icon.c-teal, .icon-badge.c-teal { background: #f0fdfa; color: #0d9488; border: 1px solid #99f6e4; }
.nav-dropdown-icon.c-indigo, .icon-badge.c-indigo { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.nav-dropdown-icon.c-magenta, .icon-badge.c-magenta { background: #fdf4ff; color: #c026d3; border: 1px solid #f5d0fe; }

/* Interactive Hover Transformation with Thematic Glow */
.nav-dropdown-item:hover .nav-dropdown-icon {
    transform: scale(1.08);
}
.nav-dropdown-item:hover .nav-dropdown-icon.c-azure { background: #2563eb; color: #ffffff; border-color: #2563eb; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-emerald { background: #059669; color: #ffffff; border-color: #059669; box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-violet { background: #7c3aed; color: #ffffff; border-color: #7c3aed; box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-amber { background: #d97706; color: #ffffff; border-color: #d97706; box-shadow: 0 4px 10px rgba(217, 119, 6, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-coral { background: #ea580c; color: #ffffff; border-color: #ea580c; box-shadow: 0 4px 10px rgba(234, 88, 12, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-rose { background: #e11d48; color: #ffffff; border-color: #e11d48; box-shadow: 0 4px 10px rgba(225, 29, 72, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-cyan { background: #0284c7; color: #ffffff; border-color: #0284c7; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-teal { background: #0d9488; color: #ffffff; border-color: #0d9488; box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-indigo { background: #4338ca; color: #ffffff; border-color: #4338ca; box-shadow: 0 4px 10px rgba(67, 56, 202, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon.c-magenta { background: #c026d3; color: #ffffff; border-color: #c026d3; box-shadow: 0 4px 10px rgba(192, 38, 211, 0.35); }
.nav-dropdown-item:hover .nav-dropdown-icon:not([class*="c-"]) {
    background: var(--primary);
    color: #ffffff;
}

.nav-dropdown-content {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.nav-dropdown-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 1px;
}

/* Mobile Drawer Accordion Styles */
.mobile-nav-group {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--dark);
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mobile-nav-header:hover, .mobile-nav-header:focus-visible {
    background-color: var(--primary-light);
    color: var(--primary);
}

.mobile-nav-header i.chevron {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform var(--transition-fast);
}

.mobile-nav-header.is-expanded i.chevron {
    transform: rotate(180deg);
}

.mobile-nav-sublist {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding-left: 8px;
    margin: 4px 0 8px;
    border-left: 3px solid var(--primary-light);
}

.mobile-nav-sublist.is-visible {
    display: flex;
}

.mobile-nav-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mobile-nav-subitem:hover, .mobile-nav-subitem:focus-visible {
    color: var(--primary-dark);
    background-color: var(--primary-light);
}

/* ==========================================================================
   12. FOOTER & MULTI-TENANCY SUBDOMAIN SIMULATOR BAR
   ========================================================================== */
.tenant-switcher-bar {
    background: #070d1e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    padding: 0.5rem 1.5rem;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.tenant-switcher-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.tenant-switcher-label i {
    color: var(--accent);
    font-size: 0.85rem;
}

.tenant-switcher-label .switcher-title {
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.tenant-switcher-label .switcher-subtext {
    color: #94a3b8;
    font-size: 0.78rem;
}

.tenant-switcher-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 122, 83, 0.25);
    border: 1px solid rgba(0, 122, 83, 0.5);
    color: #4ade80;
    padding: 2px 10px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.76rem;
    letter-spacing: 0.01em;
}

.tenant-switcher-active-badge.national-badge {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.45);
    color: #38bdf8;
}

.tenant-switcher-pills {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.tenant-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #94a3b8;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.76rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tenant-pill-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.tenant-pill-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(0, 122, 83, 0.45);
}

/* Institutional Footer */
footer {
    background: #070d1e;
    color: #cbd5e1;
    margin-top: 4rem;
    padding: 3.5rem 1.5rem 2rem;
    border-top: 3px solid var(--accent);
    position: relative;
}

.footer-container {
    max-width: 1600px;
    margin: 0 auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.1fr 1.1fr;
    gap: 3rem;
    margin-bottom: 2.5rem;
}

.footer-col h4 {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    position: relative;
    padding-bottom: 10px;
    letter-spacing: -0.01em;
}

.footer-col h4::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 36px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-col ul li {
    margin: 0;
    padding: 0;
}

.footer-col ul li a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.footer-col ul li a::before {
    content: '›';
    font-size: 1.1rem;
    color: var(--accent);
    line-height: 1;
    transition: transform 0.2s ease;
}

.footer-col ul li a:hover {
    color: #ffffff;
    transform: translateX(4px);
}

.footer-col ul li a:hover::before {
    color: #ffffff;
    transform: translateX(2px);
}

/* Footer Social Media Badges */
.footer-socials {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.footer-socials a {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.footer-socials a:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 122, 83, 0.4);
}

/* Footer Bottom Bar */
.footer-bottom {
    padding-top: 1.75rem;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.84rem;
    color: #64748b;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-bottom p {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   13. GLOBAL RESPONSIVE BEHAVIOR, ZERO-OVERFLOW & TOUCH TARGETS (WCAG 2.1 AA / 44px)
   ========================================================================== */

/* Zero-Overflow Safety Net (using clip to preserve sticky positioning) */
html, body {
    overflow-x: clip !important;
    max-width: 100% !important;
    position: relative;
}

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

/* Fluid Media Safety */
img, svg, video, canvas, iframe, object {
    max-width: 100%;
    height: auto;
}

/* Pre & Code blocks zero-spill */
pre, code, kbd, samp {
    max-width: 100%;
    word-break: break-word;
}

/* Universal Table Responsive Engine */
.table-responsive,
.table-container,
.data-table-wrapper,
[class*="-table-card"],
.table-scroll-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-md);
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.table-responsive::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.data-table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.data-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 9999px;
}

/* Touch Active Feedback & Micro-Interactions */
.btn:active,
.mobile-bottom-tab:active,
.btn-console-tab:active,
.mobile-nav-header:active,
.mobile-nav-subitem:active,
.quick-create-item:active,
.stat-card:active {
    transform: scale(0.975);
}

.btn, .btn-console-tab, .mobile-bottom-tab, .nav-link-btn {
    transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

/* Focus Visible Accessibility Rings */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Large Screens & Desktop Refinements */
@media (max-width: 1280px) {
    .grid-4col {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Tablet Adaptive Rules (768px – 1024px) */
@media (max-width: 1024px) {
    :root {
        --page-padding: var(--page-padding-tablet);
    }

    .grid-4col {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Balanced 2-column fallback for overly wide auto-fit grids */
    .pillar-grid,
    .finder-grid,
    .impact-kpi-card {
        gap: 1rem;
    }
}

/* Global Mobile & Handheld Engine (<= 768px) */
@media (max-width: 768px) {
    :root {
        --page-padding: var(--page-padding-mobile);
    }

    body {
        /* Extra padding-bottom so fixed mobile bottom bar never covers page content */
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Hide multi-tenancy simulator bar and statutory notice banner on mobile */
    .tenant-switcher-bar,
    .alert-banner {
        display: none !important;
    }

    /* Minimum 44px Touch Target Height for WCAG 2.1 AA Compliance */
    .btn,
    button[type="button"],
    button[type="submit"],
    .btn-portal-back,
    .view-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        min-height: 38px;
    }

    /* Prevent Intrusive Auto-Zoom on iOS Safari (Requires 16px minimum font size) */
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    select,
    textarea,
    .form-control,
    .form-select,
    .filter-input,
    .filter-select {
        font-size: 16px !important;
        min-height: 44px;
        line-height: 1.4;
    }

    /* Defensive Grid Scaling: Convert heavy minmax columns into flexible fluid cards */
    .grid-3col, .grid-4col {
        grid-template-columns: 1fr !important;
    }

    /* Auto-neutralize inline grid templates with rigid minmax columns */
    [style*="minmax(3"],
    [style*="minmax(28"],
    [style*="minmax(26"] {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)) !important;
    }

    /* Table Edge Bleed on Mobile with Momentum Touch Scroll */
    .table-responsive {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .data-table th, .data-table td {
        padding: 0.75rem 0.85rem;
        font-size: 0.84rem;
    }

    /* Filter & Search Form Stacking */
    .filter-bar,
    .filter-grid {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .filter-bar > *,
    .filter-grid > *,
    .filter-field {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        grid-column: auto !important;
    }

    /* Mobile Button Groups */
    .btn-group {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .btn-group .btn {
        width: 100%;
        border-radius: var(--radius-md) !important;
    }

    /* Toast Notification repositioning above bottom bar */
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
        max-width: none;
        z-index: 9995;
    }

    /* Mobile App Responsive Modals (Bottom Sheet Style) */
    .modal-dialog,
    .modal-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: auto 0 0 0 !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* Compact Mobile Screens (<= 640px) */
@media (max-width: 640px) {
    :root {
        --page-padding: var(--page-padding-compact);
    }

    h1, .h1, .text-h1 {
        font-size: clamp(1.15rem, 3.8vw, 1.4rem) !important;
        font-weight: 700 !important;
        line-height: 1.25 !important;
    }

    h2, .h2, .text-h2 {
        font-size: clamp(1.02rem, 3vw, 1.18rem) !important;
        font-weight: 700 !important;
        line-height: 1.28 !important;
    }

    h3, .h3, .text-h3 {
        font-size: clamp(0.92rem, 2.5vw, 1.08rem) !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;
    }

    h4, .h4, .text-h4 {
        font-size: clamp(0.84rem, 2.2vw, 0.98rem) !important;
        font-weight: 700 !important;
    }

    .content-card {
        padding: 1.15rem 0.95rem;
        border-radius: var(--radius-md);
    }

    .grid-2col {
        grid-template-columns: 1fr !important;
    }

    /* Collapse rigid inline grids to single column */
    [style*="minmax("] {
        grid-template-columns: 1fr !important;
    }

    /* Card header & footer spacing */
    .card-header,
    .card-body,
    .card-footer {
        padding: 0.85rem;
    }

    /* Compact pagination on mobile */
    .pagination, .pdir-pagination {
        flex-wrap: wrap;
        gap: 0.35rem;
        justify-content: center;
    }

    .pdir-page-btn, .pagination-btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.78rem;
    }
}

/* Small / Narrow Handheld Devices (<= 480px, down to 320px) */
@media (max-width: 480px) {
    body {
        font-size: 0.88rem;
    }

    h1, .h1, .text-h1 {
        font-size: clamp(1.08rem, 3.5vw, 1.3rem) !important;
    }

    h2, .h2, .text-h2 {
        font-size: clamp(0.98rem, 2.8vw, 1.12rem) !important;
    }

    h3, .h3, .text-h3 {
        font-size: clamp(0.88rem, 2.4vw, 1.02rem) !important;
    }

    .stat-card,
    .metric-card,
    .kpi-card {
        padding: 0.85rem 0.75rem;
        gap: 0.65rem;
        border-radius: var(--radius-md);
    }

    .stat-icon,
    .kpi-icon {
        width: 38px;
        height: 38px;
        font-size: 1.05rem;
        border-radius: 8px;
    }

    .stat-value,
    .kpi-value,
    .metric-val,
    .kpi-val,
    .stat-val {
        font-size: clamp(1.02rem, 4.2vw, 1.3rem) !important;
        word-break: break-word !important;
    }

    .stat-label,
    .kpi-label,
    .metric-label {
        font-size: 0.68rem;
    }

    /* Section Containers Compact Spacing */
    .section-container,
    .page-header-container,
    .content-container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

@media (max-width: 360px) {
    body {
        font-size: 0.86rem;
    }

    .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.82rem;
    }

    .stat-card,
    .kpi-card {
        padding: 0.7rem 0.65rem;
    }

    .stat-value,
    .kpi-value {
        font-size: 1.15rem !important;
    }
}

/* ==========================================================================
   14. NATIVE MOBILE APP UX & COMPACT LAYOUT ENGINE (iOS/Android Native Feel)
   ========================================================================== */
.mobile-bottom-bar {
    display: none;
}

@media (max-width: 768px) {
    /* Native Mobile App Fixed Bottom Navigation Bar with iOS Safe-Area */
    .mobile-bottom-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9990;
        min-height: 60px;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        background: rgba(7, 13, 30, 0.94);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
        justify-content: space-around;
        align-items: center;
        padding: 4px 6px max(6px, env(safe-area-inset-bottom, 6px));
    }

    .mobile-bottom-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #94a3b8;
        text-decoration: none;
        background: transparent;
        border: none;
        padding: 4px 0;
        font-family: var(--font-body);
        font-size: 0.69rem;
        font-weight: 600;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
        border-radius: 8px;
        min-height: 48px;
        touch-action: manipulation;
        position: relative;
    }

    .mobile-bottom-tab i {
        font-size: 1.15rem;
        transition: transform 0.2s ease, color 0.2s ease;
    }

    .mobile-bottom-tab:active {
        transform: scale(0.92);
    }

    .mobile-bottom-tab.active {
        color: #4ade80;
        font-weight: 800;
    }

    .mobile-bottom-tab.active i {
        color: #4ade80;
        transform: translateY(-2px);
    }

    .mobile-bottom-tab.active::after {
        content: "";
        position: absolute;
        bottom: 2px;
        width: 14px;
        height: 3px;
        background: #4ade80;
        border-radius: 9999px;
        box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    }

    /* Mobile Horizontal Scroll Carousels for Stat Cards & Action Chips */
    .mobile-scroll-carousel,
    .stat-grid-carousel {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 12px !important;
        padding: 4px 0 10px !important;
        margin-left: -0.75rem !important;
        margin-right: -0.75rem !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        scrollbar-width: none !important;
    }

    .mobile-scroll-carousel::-webkit-scrollbar,
    .stat-grid-carousel::-webkit-scrollbar {
        display: none !important;
    }

    .mobile-scroll-carousel > *,
    .stat-grid-carousel > * {
        flex: 0 0 82% !important;
        max-width: 300px !important;
        min-width: 220px !important;
        scroll-snap-align: start !important;
    }

    /* Mobile Segmented View Toggle Switcher */
    .mobile-segmented-control {
        display: flex;
        background: #e2e8f0;
        padding: 4px;
        border-radius: var(--radius-lg);
        overflow-x: auto;
        scrollbar-width: none;
        margin-bottom: 1.25rem;
        gap: 4px;
    }

    .mobile-segmented-control::-webkit-scrollbar {
        display: none;
    }

    .mobile-segmented-tab {
        flex: 1;
        min-height: 40px;
        padding: 6px 12px;
        font-size: 0.82rem;
        font-weight: 700;
        border-radius: var(--radius-md);
        border: none;
        background: transparent;
        color: var(--text-secondary);
        transition: all 0.2s ease;
        cursor: pointer;
        white-space: nowrap;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .mobile-segmented-tab.active {
        background: #ffffff;
        color: var(--primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Floating Action Button (FAB) for Mobile Quick Creation */
    .mobile-fab {
        position: fixed;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
        right: 18px;
        z-index: 9980;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--primary);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        box-shadow: 0 8px 24px rgba(0, 122, 83, 0.45);
        border: none;
        cursor: pointer;
        transition: transform 0.2s ease, background-color 0.2s ease;
    }

    .mobile-fab:active {
        transform: scale(0.92);
        background-color: var(--primary-dark);
    }

    /* National News and Notices Grid Stacking */
    .national-news-grid,
    [class*="national-news-grid"] {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 1.5rem !important;
    }
    .national-news-column {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        display: block !important;
    }
}

@media (min-width: 993px) {
    .national-news-grid {
        display: grid;
        grid-template-columns: 1.25fr 0.75fr;
        gap: 2.25rem;
    }
}

/* ==========================================================================
   15. UNIVERSAL NATIVE APP-LIKE UTILITIES (Mobile Touch & Micro-Interactions)
   ========================================================================== */

/* Native Mobile Card Primitive */
.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-mobile);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-mobile-card);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.app-card:active {
    transform: scale(0.985);
}

/* Native Mobile Metric KPI Tile */
.app-metric-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-mobile);
    padding: 0.95rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition-fast);
}

.app-metric-tile:active {
    transform: scale(0.98);
}

.app-metric-tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.app-metric-tile-num {
    font-size: clamp(1.25rem, 4vw, 1.65rem);
    font-weight: 800;
    font-family: var(--font-heading);
    line-height: 1.15;
    color: var(--text-main);
}

.app-metric-tile-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* Mobile Interactive Chip / Filter Pill */
.app-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.app-chip:active {
    transform: scale(0.95);
}

.app-chip.active,
.app-chip:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(0, 122, 83, 0.35);
}

/* Mobile Touch List View Item */
.app-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background-color var(--transition-fast);
    min-height: var(--touch-target-min);
}

.app-list-item:last-child {
    border-bottom: none;
}

.app-list-item:active {
    background: rgba(0, 0, 0, 0.03);
}

/* Sticky Form Action Floating Bar with iOS Safe-Area */
.app-sticky-bar {
    position: sticky;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-mobile);
    padding: 0.85rem 1.25rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .app-sticky-bar {
        flex-direction: column-reverse;
        padding: 0.75rem 1rem;
    }
    .app-sticky-bar > * {
        width: 100% !important;
        justify-content: center !important;
        min-height: var(--touch-target-min) !important;
        text-align: center;
    }
}

/* Universal Native App Shimmer Skeleton Utilities */
.app-skeleton {
    background: linear-gradient(90deg, rgba(226, 232, 240, 0.5) 25%, rgba(241, 245, 249, 0.9) 50%, rgba(226, 232, 240, 0.5) 75%);
    background-size: 200% 100%;
    animation: app-shimmer 1.5s infinite linear;
    border-radius: var(--radius-sm);
}

.console-app-container .app-skeleton,
[data-theme="dark"] .app-skeleton {
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.6) 25%, rgba(51, 65, 85, 0.8) 50%, rgba(30, 41, 59, 0.6) 75%);
    background-size: 200% 100%;
}

@keyframes app-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 6px;
    border-radius: 4px;
}

.skeleton-title {
    height: 22px;
    width: 60%;
    margin-bottom: 10px;
    border-radius: 6px;
}

.skeleton-circle {
    border-radius: 50% !important;
}

.skeleton-btn {
    height: var(--touch-target-min);
    border-radius: var(--radius-mobile);
}

/* Native App Momentum & Touch Active Micro-Interactions */
.app-momentum-scroller {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.app-momentum-scroller::-webkit-scrollbar {
    display: none;
}

.app-touch-active {
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.app-touch-active:active {
    transform: scale(0.96);
    opacity: 0.88;
}

/* ==========================================================================
   NATIVE MOBILE APP UI PRIMITIVES & LAYOUT SYSTEM
   ========================================================================== */

/* 1. App Launcher Tile Grid (2-column on mobile, 3-column on tablet) */
.app-launcher-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 12px 0 18px;
    width: 100%;
}

@media (min-width: 641px) and (max-width: 1024px) {
    .app-launcher-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

.app-launcher-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    padding: 14px 12px;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    min-height: 94px;
    position: relative;
    overflow: hidden;
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease, border-color 0.16s ease;
    -webkit-tap-highlight-color: transparent;
}

.app-launcher-tile:active {
    transform: scale(0.96);
    background: #f8fafc;
    border-color: var(--primary);
}

.app-launcher-tile .tile-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.app-launcher-tile .tile-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-launcher-tile .tile-desc {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-launcher-tile .tile-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1;
}

/* Specific Tile Color Accents */
.tile-accent-green .tile-icon-box { background: rgba(0, 122, 83, 0.12); color: #007a53; }
.tile-accent-blue .tile-icon-box { background: rgba(2, 132, 199, 0.12); color: #0284c7; }
.tile-accent-amber .tile-icon-box { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.tile-accent-purple .tile-icon-box { background: rgba(147, 51, 234, 0.12); color: #9333ea; }
.tile-accent-red .tile-icon-box { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
.tile-accent-emerald .tile-icon-box { background: rgba(5, 150, 105, 0.12); color: #059669; }

/* 2. iOS / Native Search Bar */
.app-search-bar {
    position: relative;
    width: 100%;
    margin-bottom: 12px;
}

.app-search-bar input {
    width: 100%;
    height: 44px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0 42px 0 38px;
    font-size: 0.88rem !important;
    color: #0f172a;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.app-search-bar input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 83, 0.15);
    outline: none;
}

.app-search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
}

.app-search-bar .clear-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
}

/* 3. Horizontal Scrollable Segmented Chips (Native Feel) */
.app-segmented-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 2px 8px;
    margin-bottom: 12px;
}

.app-segmented-bar::-webkit-scrollbar {
    display: none;
}

.app-segmented-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.app-segmented-chip:active {
    transform: scale(0.95);
}

.app-segmented-chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 122, 83, 0.28);
}

/* 4. Native App List Cell (List View) */
.app-list-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 12px;
    padding: 11px 12px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 8px;
    transition: background 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.app-list-cell:active {
    background: #f8fafc;
    transform: scale(0.98);
}

.app-list-cell .cell-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.app-list-cell .cell-body {
    flex: 1;
    min-width: 0;
}

.app-list-cell .cell-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-list-cell .cell-subtitle {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-list-cell .cell-chevron {
    font-size: 0.8rem;
    color: #cbd5e1;
    flex-shrink: 0;
}

/* 5. Mobile Native App Top Bar */
@media (max-width: 768px) {
    .native-app-top-bar {
        position: sticky;
        top: 0;
        z-index: 1020;
        height: 52px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(226, 232, 240, 0.9);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
    }
}
